TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

How We Improved Reliability of our WebSocket Connections

41 点作者 philfreo超过 3 年前

8 条评论

moffkalast超过 3 年前
&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 未加载
robinjhuang超过 3 年前
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 未加载
politician超过 3 年前
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 未加载
acknackack超过 3 年前
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 未加载
david422超过 3 年前
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.
heliostatic超过 3 年前
&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.
hungnv超过 3 年前
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.
renewiltord超过 3 年前
This is why so many crypto exchanges send ping and pongs periodically as requests and not as control.<p>It’s application layer keepalive.