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

fix(engineio): respect pingTimeout and pingInterval to stop connection #359

Merged
merged 1 commit into from
Mar 31, 2024

Conversation

sirkrypt0
Copy link
Contributor

The Engine.IO protocol features a heartbeat mechanism which ensures that the connection between server and client is alive. During that heartbeat, the server sends PINGs to which the client responds with PONGs. Both parties can therefore detect whether the connection is still alive, based on the pingInterval and pingTimeout received in the initial handshake.

However, we previously didn't make use of that in the Engine.IO implementation, which lead to disconnects not being properly recognized.

We now respect these settings and return an error and disconnect the connection, once the pingInterval+pingTimeout time has passed.

See also https://socket.io/docs/v4/how-it-works/#disconnection-detection

Closes #358

@codecov
Copy link

codecov bot commented Sep 26, 2023

Codecov Report

Attention: 9 lines in your changes are missing coverage. Please review.

Comparison is base (38f20fc) 90.78% compared to head (cbbe483) 90.69%.
Report is 5 commits behind head on main.

Files Patch % Lines
engineio/src/asynchronous/async_socket.rs 83.87% 5 Missing ⚠️
engineio/src/socket.rs 87.50% 2 Missing ⚠️
engineio/src/transports/websocket.rs 83.33% 1 Missing ⚠️
engineio/src/transports/websocket_secure.rs 75.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #359      +/-   ##
==========================================
- Coverage   90.78%   90.69%   -0.10%     
==========================================
  Files          37       37              
  Lines        4708     4759      +51     
==========================================
+ Hits         4274     4316      +42     
- Misses        434      443       +9     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Owner

@1c3t3a 1c3t3a left a comment

Choose a reason for hiding this comment

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

Thanks a lot for this PR! I would love to merge it after you reacted to @ctrlaltf24's comments, would be great if you could keep the stream impl!

engineio/src/asynchronous/async_socket.rs Show resolved Hide resolved
The Engine.IO protocol features a heartbeat mechanism which ensures that the
connection between server and client is alive. During that heartbeat, the
server sends PINGs to which the client responds with PONGs. Both parties
can therefore detect whether the connection is still alive, based on the
pingInterval and pingTimeout received in the initial handshake.

However, we previously didn't make use of that in the Engine.IO implementation,
which lead to disconnects not being properly recognized.

We now respect these settings and return an error and disconnect the connection,
once the pingInterval+pingTimeout time has passed.

See also https://socket.io/docs/v4/how-it-works/#disconnection-detection
Copy link
Owner

@1c3t3a 1c3t3a left a comment

Choose a reason for hiding this comment

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

Decided to land this after all. We're doing a breaking release now anyways and this is a well needed bugfix!

@1c3t3a 1c3t3a merged commit d64a54c into 1c3t3a:main Mar 31, 2024
4 checks passed
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.

EngineIO does not timeout on missing pings
3 participants