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
Ping-pong for latency doesnt seem to work anymore #1400
Comments
After reading v3 documentation I noticed Is there any workaround at the moment? |
Also this mentioned in following commit: Seems this feature was removed due engine.io... |
@hadimostafapour Good find!!! :) |
Hi! You are absolutely right, this should be included in the migration guide. You should be able to reproduce the behavior with: // server-side
io.on("connection", (socket) => {
socket.on("ping", (cb) => {
if (typeof cb === "function")
cb();
});
});
// client-side
setInterval(() => {
const start = Date.now();
socket.volatile.emit("ping", () => {
const latency = Date.now() - start;
// ...
});
}, 5000); |
@darrachequesne Thanks for the code snippet!! |
Thanks for the feedback 👍 |
You want to:
Current behaviour
What is actually happening?
Pong event on the client is not fired/triggered, even with pingInterval enabled/set on the server
Steps to reproduce (if the current behaviour is a bug)
https://github.com/Tiboonn/socket.io-fiddle
In the fork above the version of socket.io and socket.io-client are 3.0.0 which the 'pong' event doesnt work on.
If you change both versions in the packege.json to 2.3.0 and reinstall the packages the 'pong' event is working
Expected behaviour
What is expected?
I am expecting to get the latency is ms with the following code block on the client side
Setup
Other information (e.g. stacktraces, related issues, suggestions how to fix)
The text was updated successfully, but these errors were encountered: