-
Notifications
You must be signed in to change notification settings - Fork 177
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
refactor(client): unify ws ping/pong API with the server #1258
Conversation
2c14268
to
5aa1ff8
Compare
if let Err(err) = sender.send_ping().await { | ||
tracing::error!(target: LOG_TARGET, "Could not send ping frame: {err}"); | ||
break Err(Error::Custom("Could not send ping frame".into())); | ||
} | ||
} | ||
} | ||
} |
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.
Nice to de-duplicate these bits :)
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.
Looks solid to me; good job!
/// | ||
/// Such that the `inactive_limit` should be configured to longer than a single | ||
/// WebSocket ping takes or it might be missed and may end up | ||
/// terminating the connection. |
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.
nit: Might be worth stating the default values
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.
Nice one! 👍
This changes the clients to support a similar WebSocket ping/pong as the server which
was introduced in #1248
The
PingConfig
type is duplicated in the server and client but I'm fine with that for now.After introducing
Instant
in code I realized that the ping/pong interval would panic in wasm and I have removed ping/pongs completely because gloo-net doesn't support that anyway.The other solution is to use some other crates where instants/interval stream are supported but it's not worth the effort IMHO and I think there was some reason in JS land where it's not possible to have client-side initiated pings.