-
Notifications
You must be signed in to change notification settings - Fork 240
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
How can I send pong frames as heartbeats from a client? #329
Comments
You can just send |
Welp, mentioned issue says
Is this no longer valid? |
This is valid, but this is not so different from other (non-ping) communications. Reading includes |
@hibnikar I've just read your question and checked the aforementioned issue. If I got your use case right, then yes—the solution that you proposed should achieve the behavior you want. However, beware that your task must not yield between Unfortunately, I can't think of a better way to handle this situation without some drawbacks. Ideally, we would need to solve the original issue to allow for the handling of such cases in a more elegant way. Currently, close and pong frames are handled in a special way (which is good if you want a simple/typical behavior but not particularly useful when your logic is a bit more sophisticated). Hope this helps. |
Suppose I have a client that listens to messages from WS server and simply persits them somewhere else. Server periodically sends ping frames and
tungstenite-rs
automatically responds with proper pong frames.However, now the server has introduced a requirement to periodically send pong frames with some custom content as a way to show that the client is still interested in updates.
I've quickly found this comment in
tungstenite-rs
repo where you are advised to invokewrite_pending()?
to make sure default pong response is not overwritten with the custom one and only then sending custom pong frame.But how do i do this in
tokio-tungstenite
?Is doing something like
would work? Would this work in case the code sends a lot of data to the server or is there a better way to handle this?
The text was updated successfully, but these errors were encountered: