Skip to content

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

Merged
jmigual merged 4 commits into
socketio:masterfrom
TorMFinn:master
Mar 9, 2022
Merged

Re-enable ping timeout behaviour for 3x branch#351
jmigual merged 4 commits into
socketio:masterfrom
TorMFinn:master

Conversation

@TorMFinn

@TorMFinn TorMFinn commented Mar 9, 2022

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

jmigual commented Mar 9, 2022

Copy link
Copy Markdown
Collaborator

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

TorMFinn commented Mar 9, 2022

Copy link
Copy Markdown
Contributor Author

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