Skip to content
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 support for server heartbeats #39

Merged
merged 3 commits into from
Jul 14, 2024

Conversation

alberts-s
Copy link
Contributor

@alberts-s alberts-s commented Jun 16, 2024

Before this change the websocket server would not have any heartbeat mechanism, this meant that unless the client proactively implements heartbeats the server would close the connection. From what I have seen most non-browser clients do not implement heartbeats (e.g filebeat, websocat), thus for those clients the connection would have been closed in 65 seconds.

The Websocket RFC does not set out a requirement which side should initiate heartbeats or that they are required. Most browsers have implemented heartbeats from client side, however it is not a must thus, in my opinion it is beneficial for the server to implement them, especially if the server closes connection if heartbeat is not received. This would allow to support clients which aren't browsers.

@alberts-s alberts-s force-pushed the implement-server-pings branch from c8a3227 to 7e53f8a Compare June 16, 2024 10:05
@d-Rickyy-b
Copy link
Owner

Thank you for your effort! I agree that server side pings would be beneficial for clients that don't support sending out heartbeats.

If the PR is ready to merge, please add a line to the changelog.md that describes your change.

Before this change the websocket server would not have any heartbeat mechanism,
 this meant that unless the client proactively implements heartbeats the server
 would close the connection. From what I have seen most non-browser clients do
 not implement heartbeats (e.g filebeat, websocat), thus for those clients the
 connection would have been closed in 65 seconds.

The Websocket RFC does not set out a requirement which side should initiate
 heartbeats or that they are required. Most browsers have implemented heartbeats
 from client side, however it is not a must thus, in my opinion it is beneficial
 for the server to implement them, especially if the server closes connection if
 heartbeat is not received. As a consequence this changeset allows to support
 clients which aren't browsers.
@alberts-s alberts-s force-pushed the implement-server-pings branch from 0012acd to 41bc270 Compare June 16, 2024 12:01
@alberts-s alberts-s changed the title Implement server heartbeats Add support for server heartbeats Jun 16, 2024
@alberts-s alberts-s marked this pull request as ready for review June 16, 2024 12:08
@alberts-s
Copy link
Contributor Author

Hi @d-Rickyy-b,
Thanks for the feedback and for the certstream server implementation in Go :)
I have updated the changelog.

While this is great for debugging purposes, this rather spams the log with a large number of clients.
I ignored them before, and even though it's unlikely for errors to occur here, It's better to handle them properly.
@d-Rickyy-b d-Rickyy-b merged commit 2b5971c into d-Rickyy-b:master Jul 14, 2024
3 checks passed
@d-Rickyy-b
Copy link
Owner

Hi @alberts-s and sorry for the late response. I had plenty of things going on and only now am able to properly review and test your changes. Despite the changes not being very huge, I still want to make sure everything is working properly. Thank you for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants