-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add WebSocket Ping/Pong #306
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment on lines 225-226 is no longer accurate.
|
Also, I'm not an expert on network protocols, but it appears that the WS implementations on iOS and in Safari and Chrome employ TCP keepalive, as all these clients detect when the socket has unexpectedly closed and hasn't sent a close packet (e.g. I kill the server process) and the clients detect the closure without trying to send any application-level data. My understanding is that TCP keepalive is considered less reliable due to things like web proxies, where keepalive could only tell you that your connection to the proxy is still running but a WS-level ping would actually hit the server. I don't think this would be an issue on boat, but my past record of being correct when I think, "of course the boat's network wouldn't do that" isn't great. |
I don't see any use case in the server needing to initiate sending control frames (a la ping) to clients. Server doesn't care if you're connected or not other than if you have a Traefik is the expected termination point for any TCP connection from a client to the server while on board. Traefik to Swiftarr communication should be nearly 100% reliable. What happens between client and Traefik is where we get spicy. Thinking out loud from the client perspective of implementing this healthcheck method, I'd need something like this:
In Tricordarr this likely involves some |
I am going to close this until a more concrete need comes up. |
This closes #187. Since browser clients do not implement WebSocket control frames, the native ping/pong mechanism is unavailable. it is left to the client/server protocol vendors to develop their own solution. This gives native clients the ability to make smarter healthcheck functions to determine the liveness state of the socket. For example, Tricordarr currently does a simple check based on the WS state https://github.com/jocosocial/tricordarr/blob/main/src/libraries/Network/Websockets.ts#L84-L91.
It is entirely possible this is a solution in search of a problem. On-board I feel like the auto reconnection library in Tricordarr seemed to work pretty well since roaming to an area with bad network closed the socket and it attempted to reconnect a few times before giving up. But I don't have specific anecdotes to confirm or deny this.