Skip to content

Re-enable ping timeout behaviour for 3x branch #351

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

Merged
merged 4 commits into from
Mar 9, 2022

Conversation

TorMFinn
Copy link
Contributor

@TorMFinn TorMFinn commented Mar 9, 2022

After this commit ec4d540 the ping timeout behavior was broken.

Fixes:

  • Re-enable ping timeout handling.
  • Remove ping function that was unused.

TorMFinn and others added 4 commits March 8, 2022 19:35
Comment on lines 463 to 464
{
if (m_ping_timeout_timer) {
asio::error_code ec;
m_ping_timeout_timer->expires_from_now(milliseconds(m_ping_timeout),ec);
m_ping_timeout_timer->async_wait(std::bind(&client_impl::timeout_pong, this, std::placeholders::_1));
}
// Parse the incoming message according to socket.IO rules
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't you call update_ping_timeout_timer() here?

Suggested change
{
if (m_ping_timeout_timer) {
asio::error_code ec;
m_ping_timeout_timer->expires_from_now(milliseconds(m_ping_timeout),ec);
m_ping_timeout_timer->async_wait(std::bind(&client_impl::timeout_pong, this, std::placeholders::_1));
}
// Parse the incoming message according to socket.IO rules
{
update_ping_timeout_timer()
// Parse the incoming message according to socket.IO rules

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could re-add this, but I'm not sure it's "correct" behaviour to essentially treat every received message from the server as a "ping". I have checked the client implementation for Java script, and it seems like that client only updates the timer on a ping package also.

https://github.com/socketio/socket.io-client/blob/master/dist/socket.io.js

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right. The server is the one periodically sending ping packets that the client must reply. For more info see: https://socket.io/docs/v4/how-it-works/#disconnection-detection

@jmigual
Copy link
Collaborator

jmigual commented Mar 9, 2022

Hi @TorMFinn thanks for your contribution! If you could answer my question and change it (if necessary) then this PR will be ready to go 😊

@TorMFinn
Copy link
Contributor Author

TorMFinn commented Mar 9, 2022

Hi @jmigual I have commented on your question :)

@jmigual jmigual merged commit 5a0c1ec into socketio:master Mar 9, 2022
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

Successfully merging this pull request may close these issues.

2 participants