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

feat: detect closed connections with TCP keepalive #712

Merged
merged 1 commit into from
Jun 27, 2024
Merged

Conversation

EvanHahn
Copy link
Contributor

If two peers connect and one disconnects, the other won't necessarily know.

  1. Alex and Charlie connect. Alex sees that they are connected to 1 device.
  2. Charlie disconnects from wifi. Alex still sees a connection to 1 device, even though the connection should be broken.

We can fix this in several ways. I think the best is to enable TCP keepalive, which effectively sends a packet every second asking, "is this connection still on?".

I did not add unit tests for this (I could not think of a good way) but did test manually in CoMapeo with two Android devices.

If two peers connect and one disconnects, the other won't necessarily
know.

1. Alex and Charlie connect. Alex sees that they are connected to 1
   device.
2. Charlie disconnects from wifi. Alex still sees a connection to 1
   device, even though the connection should be broken.

We can fix this in several ways. I think the best is to enable
[TCP keepalive], which effectively sends a packet every second asking,
"is this connection still on?".

I did not add unit tests for this (I could not think of a good way) but
did test manually in CoMapeo with two Android devices.

[TCP keepalive]: https://tldp.org/HOWTO/TCP-Keepalive-HOWTO/overview.html
@EvanHahn EvanHahn requested a review from achou11 June 26, 2024 21:44
Copy link
Member

@gmaclennan gmaclennan left a comment

Choose a reason for hiding this comment

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

Great, glad to see a solution to this!

@EvanHahn EvanHahn merged commit f480798 into main Jun 27, 2024
7 checks passed
@EvanHahn EvanHahn deleted the tcp-keepalive branch June 27, 2024 13:35
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