-
Notifications
You must be signed in to change notification settings - Fork 7.2k
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
Websocket handling: client side pings kill ws-connection. #17197
Comments
We are also seeing this issue as it affects the mattermost driver and anyone using that driver. |
Opened a ticket for investigation https://mattermost.atlassian.net/browse/MM-34158. |
This appears to have been caused inadvertently by #16620, which changed the websocket library in use. The old library was fairly high level and had default handling of ping messages:
The new implementation is lower level and doesn't handle this for users, requiring them to implement this functionality themselves. This should be done here: |
Thank you @someone-somenet-org and @attzonko for the report, and thank you @elyscape for the analysis! The Mattermost server wasn't really explicitly handling pings from clients. It seems to be a default behavior from the old implementation which other clients seemed to rely on. The client is only meant to respond to ping messages with a pong, as our official Go websocket client (https://pkg.go.dev/github.com/mattermost/mattermost-server/v5/model#WebSocketClient) does. The workaround is to disable making explicit pings and only respond to pongs from the server. In any case, closing the connection is incorrect behavior, and we will be fixing this. Thanks everyone. |
@agnivade From the spec, it seems that a |
Sorry for any confusion there. The fix will be to respond with a pong frame. But until then, the workaround is to not make explicit pings. For a better solution, I would suggest not to send ping frames at all, as the server already does that. |
OK, that makes sense. However, it is not very practical for us to disable the client-side ping, since the WebSocket connection is handled by a library twice removed from our Bot framework, and the intermediate library does not provide a way to disable the client pings. I'll try and work with those owners to get that functionality added, however from their standpoint the server is the one that is not adhering to the spec by not responding to the ping. |
We have reverted the feature, and it's already merged to master. So I will close the issue. A dot release for 5.33.2 should be out soon. Thanks everyone! |
It seems that Mattermost's websocket handling of client side pings is broken since the 5.33.x update.
Instead of responding to ping frames (which is a MUST) MM now just silently drops the websocket connection.
I can reliably reproduce the loss of connection and work around the issue by disabling said client ping logic.
It also seems to affect matterhorn a mattermost terminal client.
Summary
Websocket handling of ping frames is broken with MM 5.33.1.
Steps to reproduce
For example use python3 websockets lib.
Counter-example: (added
ping_interval=None
to connect)Expected behavior
MM responding to client side ping frames as required by the RFC: https://tools.ietf.org/html/rfc6455#section-5.5.2
Observed behavior (that appears unintentional)
Websocket connection is silently dropped after a ping request from client.
The text was updated successfully, but these errors were encountered: