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
Hi there, sorry if my issue is silly, I'm still amateur in websockets handling. I'm facing a problem where I couldn't disconnect properly using sockette when the network is offline. I'm currently using sockette to connect with my Websocket API using AWS API Gateway, everything seems fine except when I realized that the connections created by the gateway isn't always being disconnected thus leaving many dead connection records in my DynamoDB. This is how I replicate the issue:
Open new tab and access to my website with websocket connection, wait until it's connected
Turn off my laptop WiFi connection, to simulate offline connection
Close the tab
Turn on my laptop WiFi connection
I'm wondering do Sockette handles such situation, at least have a callback when offline connection is detected? If it's already available, how can I modify my code to cater for that? This is my code in React:
useEffect(
() => {
if (isProduction) {
webSocket = new Sockette(webSocketUrlFor(userId), {
timeout: 5e3,
onopen: e => console.log('Connected', e),
onmessage: onReceivedMessage,
onreconnect: () => console.log('Reconnecting...'),
onmaximum: e => console.log('Stop Attempting!', e),
onclose: e => {
console.log('Closed connection. Reconnecting...', e);
webSocket.reconnect();
},
onerror: e => console.log('Error:', e)
});
return () => {
webSocket.close();
};
}
},
[userId]
);
The text was updated successfully, but these errors were encountered:
In this case you would have to catch/listen for the disconnection from the server side's point of view. This is because your client unexpectedly shuts down (for whatever reason), so there's no chance to send a ws.close() or even a Going Away code. The network is gone so there's no ability to send anything.
I don't use AWS for WS, so I can't help much beyond linking to what looks to be relevantdocs.
Hi there, sorry if my issue is silly, I'm still amateur in websockets handling. I'm facing a problem where I couldn't disconnect properly using sockette when the network is offline. I'm currently using sockette to connect with my Websocket API using AWS API Gateway, everything seems fine except when I realized that the connections created by the gateway isn't always being disconnected thus leaving many dead connection records in my DynamoDB. This is how I replicate the issue:
I'm wondering do Sockette handles such situation, at least have a callback when offline connection is detected? If it's already available, how can I modify my code to cater for that? This is my code in React:
The text was updated successfully, but these errors were encountered: