Open harikt opened 8 months ago
As an alternative approach this is what I did. If this helps anyone.
// Ping every 60 second
const HEARTBEAT_INTERVAL = 60000;
useEffect(() => {
// Start heartbeat interval
const heartbeatInterval = setInterval(() => {
sendJsonMessage({
type: 'ping'
});
}, HEARTBEAT_INTERVAL);
// Clean up interval on component unmount
return () => clearInterval(heartbeatInterval);
}, [sendJsonMessage]);
Hey,
I have been experimenting with the heartbeat feature and as reported on comment https://github.com/robtaussig/react-use-websocket/pull/206#issuecomment-1867894798 , this seems not sending any messages via websocket.
Option 2 for heartbeat
Option 3 for heartbeat
Note : You can see one of the option I choose is
skipAssert: true,
. This was because of error I was gettingSo using
skipAssert: true,
has fixed the error. The note probably is another issue I should open.