Skip to content

Commit

Permalink
socket: disable heartbeat check on client side socket
Browse files Browse the repository at this point in the history
  • Loading branch information
b-ma committed Apr 25, 2024
1 parent 784caae commit 19fff13
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions src/client/Socket.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,20 +138,25 @@ class Socket {
ws.addEventListener('open', connectEvent => {
// parse incoming messages for pubsub
this.ws = ws;
// ping / pong to check connection
const heartbeat = () => {
clearTimeout(this._heartbeatId);

this._heartbeatId = setTimeout(() => {
this.terminate();
}, PING_INTERVAL + PING_LATENCY_TOLERANCE);
};
// Heartbeat ping / pong check, to detect if connection has been
// broken but not detected by the client
// @note (2024-04): unstable and creates more issues than it solves, disable
// for now and review later
// const heartbeat = () => {
// clearTimeout(this._heartbeatId);

// this._heartbeatId = setTimeout(() => {
// console.log('> HEARTBEAT missed, closing...');
// this.terminate();
// }, PING_INTERVAL + PING_LATENCY_TOLERANCE);
// };

heartbeat();
// heartbeat();

this.ws.addEventListener('message', e => {
if (e.data === PING_MESSAGE) {
heartbeat();
// heartbeat();
this.ws.send(PONG_MESSAGE);
// do not propagate ping / pong messages
return;
Expand Down

0 comments on commit 19fff13

Please sign in to comment.