Description
Hello everyone! First of all, thank you for this library, saves me a ton of time.
So I tried to use the heartbeat feature. On version 4.11.1 I experienced that the "ping" message doesn't send therefore it just timeouts because there is no response from the server (because the server doesn't receive a "ping" message), so I downgraded to version 4.8.1 (#255) and it worked. But now after heartbeat timeouts and there are no responses from the server nothing happens. I expect a closing connection after heartbeat timeouts, am I missing something or do I understand the logic wrong?
This is my options with heartbeat:
shouldReconnect: (closeEvent) => {
return (
shouldConnect &&
reconnectAttemptsRef.current < RECONNECT_INTERVALS.length
);
},
reconnectAttempts: RECONNECT_INTERVALS.length,
reconnectInterval: (attemptNumber) => {
reconnectAttemptsRef.current = attemptNumber + 1;
setCurrentReconnectAttempt(attemptNumber + 1);
return (
RECONNECT_INTERVALS[attemptNumber] ||
RECONNECT_INTERVALS[RECONNECT_INTERVALS.length - 1]
);
},
onClose: () => {
console.log(
`WebSocket closed. Attempt ${reconnectAttemptsRef.current} of ${RECONNECT_INTERVALS.length}`
);
if (restOptions?.onClose) {
restOptions.onClose();
}
},
heartbeat: {
message: JSON.stringify({ action: "ping", request_id: "0" }),
returnMessage: JSON.stringify({
errors: [],
data: { message: "Pong!" },
action: "ping",
response_status: 200,
request_id: "0",
}),
timeout: restOptions?.heartbeatTimeout || HEARTBEAT_TIMEOUT,
interval: restOptions?.heartbeatInterval || HEARTBEAT_INTERVAL,
},
The "ping" message sends and even if there is no response from the server - it sends the next "ping" message and then just stops and does nothing.