TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

How We Improved Reliability of our WebSocket Connections

41 pointsby philfreoover 3 years ago

8 comments

moffkalastover 3 years ago
&gt; The (sadly all too) common approach to rarely occurring bugs &amp; edge cases: Pretend like the problem doesn&#x27;t exist. Blame it on faulty networking, solar flares, etc.<p>How to tell if someone hasn&#x27;t been working with a piece of software in production yet? They&#x27;ve never blamed a bug on cosmic radiation yet :D
评论 #29027656 未加载
robinjhuangover 3 years ago
I think socket.io handles this client keep alive automatically.<p><a href="https:&#x2F;&#x2F;socket.io&#x2F;docs&#x2F;v4&#x2F;how-it-works&#x2F;" rel="nofollow">https:&#x2F;&#x2F;socket.io&#x2F;docs&#x2F;v4&#x2F;how-it-works&#x2F;</a><p>See disconnection detection section
评论 #29028765 未加载
评论 #29028769 未加载
politicianover 3 years ago
Good to know that WebSocket API is broken by design. Thanks W3C!<p><a href="https:&#x2F;&#x2F;www.w3.org&#x2F;Bugs&#x2F;Public&#x2F;show_bug.cgi?id=13104" rel="nofollow">https:&#x2F;&#x2F;www.w3.org&#x2F;Bugs&#x2F;Public&#x2F;show_bug.cgi?id=13104</a>
评论 #29027966 未加载
评论 #29027815 未加载
acknackackover 3 years ago
A classic issue of TCP half open connection. The client&#x2F;browser side still thinks that the websocket&#x2F;TCP connection is still alive. It happens because the client is not actively sending any data outbound, which would have helped to reset that connection eventually. It will be nice if the browser side of the websocket connection can also start PING&#x2F;PONG mechanism.
评论 #29029849 未加载
david422over 3 years ago
Interesting read, thanks. I&#x27;ve delved into websockets and hit some interesting issues. I don&#x27;t think I&#x27;ve had this scenario - that I know of - but this is good to know.
heliostaticover 3 years ago
&gt; You need to prove that what you think your code does is truly what happens.<p>Such a good insight -- seems obvious, but too often the source of gotchas, bad data, and bad user experience.
hungnvover 3 years ago
This is practical implementation when working with websocket. When server got an error or timeout waiting for client pong, it closes the connection, at the same time client send “health check” message without receive reponse (whatever message value of your choise) it closes the connection and reconnect.
renewiltordover 3 years ago
This is why so many crypto exchanges send ping and pongs periodically as requests and not as control.<p>It’s application layer keepalive.