Skip to content
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

[Heartbeat question] is a ping/pong cycle skipped if a 'standard' message is received on the websocket? #261

Open
1nfm1k3 opened this issue Feb 12, 2025 · 2 comments

Comments

@1nfm1k3
Copy link

1nfm1k3 commented Feb 12, 2025

I configured a websocket with a pretty standard heartbeat configuration:

heartbeat: {
      message: 'ping',
      returnMessage: 'pong',
      interval: 10000,
      timeout: 60000
    }

However, I noticed that no ping/pong exchanges were happening in my use case. So, I lowered down the interval to something like 1000, and at that point I could see the ping/pong messages being sent.

Finally, I realized the backend sends a message on this websocket roughly every ~5 seconds. Is this what is preventing the ping messages from being sent by the client? Or, more generally: receiving a 'standard' message on the websocket clears up a ping/pong cycle or am I misunderstanding something?

Using ^4.13.0.

@briancoit
Copy link

It seems this is a bug introduced after 4.9.0 - pings appear to be suppressed by received messages.

@1nfm1k3
Copy link
Author

1nfm1k3 commented Feb 20, 2025

From my experience with the ping/pong feature, I suppose there may be some issues related to dirty timestamps also with reconnections (the ones happening with shouldReconnect, reconnectAttempts, reconnectInterval options, and also with switching the connect hook parameter) - sometimes, I've observed ping/pongs not being sent in the reconnected subsequent websockets.

I'm sorry not being able to provide a reproducible example or codebox, since for the time being I implemented a custom ping-pong hook on top of the existing websocket.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants