5 ms·
The biggest issue with TCP is that it can randomly freeze and you have to restart it in pretty much any network. You CAN NOT rely on socket closing on any side,
by ex3ndr 6y ago
The biggest issue with TCP is that it can randomly freeze and you have to restart it in pretty much any network. You CAN NOT rely on socket closing on any side, you have to maintain connection by yourself.
I am super puzzled why something like websockets not solving this problem, simple heartbeat could solve the problem, but no one implements it.
- gsich 6y agoYou can use keepalives at the protocol (TCP) level.
- ex3ndr 6y agoIn 99% of cases you don't have an api to do so.
- gsich 6y agoThat's not the protocols fault. Besides, the OS usually does this, not your program. SO_KEEPALIVE is available on all relevant OS.
- Sami_Lehtinen 6y agoDefault keepalive time of two hours is also quite long, in some situations, where you would expect to get the notification just a bit faster.
- gsich 6y agoYes, default values are not sane for most connections.
- ex3ndr 6y agoGood luck access this from browser.
- gsich 6y agoBrowsers can do this.
- ex3ndr 6y agoAha, show me how i can access low level TCP stuff from JS. Browsers could do this, but they would not.
- gsich 6y agoThere is no need for that in JS. Browser (and any other program) can open connections with SO_KEEPALIVE.
- ex3ndr 6y agoI bet they could not. It will ruin whole internet with little gain since you still need application level pings anyway because issue could be in a broken server, not on TCP level.
- gsich 6y agohttps://chromium.googlesource.com/chromium/src/+/master/net/socket/tcp_socket_posix.cc https://chromium.googlesource.com/chromium/src/+/master/net/... I don't see how this breaks the whole Internet. Yes the server might not behave, but that's not a TCP problem.
- ex3ndr 6y agoi bet you missed the times when uTorrent turned on uTP and almost everywhere in the world ISP hardware just failed because of x100 traffic.
- kccqzy 6y agoWebsockets certainly has simple heartbeats. It has Ping and Pong frames defined in the spec: https://html.spec.whatwg.org/multipage/web-sockets.html#ping-and-pong-frames https://html.spec.whatwg.org/multipage/web-sockets.html#ping... The libraries I use tend not to enable it by default, but they are generally implemented.
- ex3ndr 6y agoYes, they are just not implemented anywhere. Even MDN is not mentioning it: https://developer.mozilla.org/en-US/docs/Web/API/WebSocket https://developer.mozilla.org/en-US/docs/Web/API/WebSocket
- kccqzy 6y agoMDN doesn't mention it because MDN is focused on web developers writing code for browsers. Pings are sent from the server to the browser. Browsers are supposed to automatically send Pongs back to the server. So a client implementation has no reason to know about Pings or Pongs—it's handled by the server or the browser.
- ex3ndr 6y agoNo one cares about server side pings. On server it is not an issue at all - feel free to hold dead connections for a while. Networking issues are always on customer side, you have to detect it from the app otherwise it will literally freeze.