question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Ping-pong for latency doesnt seem to work anymore

See original GitHub issue

You want to:

  • report a bug
  • request a feature

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

socket.on('pong', function (ms) {
    console.log(ms)
})

Setup

  • OS: Ubuntu 20.04
  • browser: Firefox/Chrome (tested multiple)
  • socket.io version: 3.0.0

Other information (e.g. stacktraces, related issues, suggestions how to fix)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
darrachequesnecommented, Nov 12, 2020

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);
Read more comments on GitHub >

github_iconTop Results From Across the Web

socket.io-client - Ping-pong for latency doesnt seem to work ...
Socket.io-client: Ping-pong for latency doesnt seem to work anymore ... socket.io-client are 3.0.0 which the 'pong' event doesnt work on.
Read more >
help PingPong delay understanding and tuning - Effects Forum ...
I was unsuccessful in finding a free 64 bit Windows delay plugin that does this. lkjb PitchedDelay looks like it should do this...
Read more >
Ping-Pong Delay With Outboard FX Only (Not ITB). - Gearspace.com
I think the effect used to be created by feeding a mono delay (panned left) then sending the return to a 2nd mono...
Read more >
Why Your Ping-Pong Table Doesn't Make Me Want to Work for ...
Companies advertise perks during hiring because they perpetuate a certain level of commitment to their employees. They're a way to show ...
Read more >
RIP ping-pong. The era of wacky office perks is dead
Regardless of how work evolves in the future, LaGree believes that workers will continue to prize respect, and suggests that companies make ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found