You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
const{sendMessage, lastMessage, readyState}=useWebSocket(WEBSOCKET_URL,{heartbeat: {message: 'ping',returnMessage: 'pong',timeout: 2000,interval: 1000,},onClose:()=>{console.log("WebSocket connection closed")},shouldReconnect: (closeEvent)=>{/* useWebSocket will handle unmounting for you, but this is an example of a case in which you would not want it to automatically reconnect */console.log("try reconnect")returntrue},reconnectAttempts: 2,reconnectInterval: 2000,});
But the heartbeat is not working like expected / described in the doc.
The heartbeat is send in the specified interval. But the timeout is not working. With these settings I would except that after 2000ms (2s) of receiving the last pong the ready state would change to closed. But this is not happing. The heartbeat continues sending producing this message in the console react-use-websocket.js?v=b1dceef9:142 WebSocket is already in CLOSING or CLOSED state. The. logging of the message start roughly after two seconds of the last received pong and continues for around a minute (the default value?) only after this the readystate is changed to closed.
The text was updated successfully, but these errors were encountered:
Im using the websocket like this
But the heartbeat is not working like expected / described in the doc.
The heartbeat is send in the specified interval. But the timeout is not working. With these settings I would except that after 2000ms (2s) of receiving the last pong the ready state would change to
closed
. But this is not happing. The heartbeat continues sending producing this message in the consolereact-use-websocket.js?v=b1dceef9:142 WebSocket is already in CLOSING or CLOSED state.
The. logging of the message start roughly after two seconds of the last received pong and continues for around a minute (the default value?) only after this thereadystate
is changed to closed.The text was updated successfully, but these errors were encountered: