News for hackers. Stuff that matters.
Re:Ask HN: How do you handle WebSocket connections reconnect... by austin-cheney on Saturday June 03, 2023 @05:08AM (#36174975)
I wrote my own web socket library so that I can integrate authentication into the connection handshake. Since I have my own library I also wrote conventions to automatically attempt reconnects in 15 second intervals when the connection drops.

https://github.com/prettydiff/share-file-systems/blob/master...

Re:Ask HN: How do you handle WebSocket connections reconnect... by jtokoph on Saturday June 03, 2023 @11:54AM (#36177663)
You may want to consider adding a random jitter and backoff to the reconnect logic. Otherwise, if the server goes down and comes back up, all clients will reconnect at the same time and overload the server.
Re:Ask HN: How do you handle WebSocket connections reconnect... by dangitnotagain on Saturday June 03, 2023 @12:33PM (#36178055)
This is great! The whole project is useful. Thanks!
Re:Ask HN: How do you handle WebSocket connections reconnect... by hayst4ck on Monday June 05, 2023 @08:11PM (#36206276)
Look into exponential backoff with jitter. 15 second retry logic sounds like bad news.