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

Detect TCP server disconnection #129

Merged
merged 4 commits into from
Apr 26, 2022
Merged

Detect TCP server disconnection #129

merged 4 commits into from
Apr 26, 2022

Conversation

CBielstein
Copy link
Owner

Description

The current strategy for handling TCP connection interruptions is to rely on an exception on connection disruption. However, if a remote server respectfully closes the connection (as opposed to the connection being interrupted), no exception is generated and the read methods will continue to return empty strings, causing our code to never detect the disconnect and receive empty messages without stopping.

This change pipes through the connection state of the underlying TcpClient to check connection on each cycle of the receive loop. This allows the code to detect a disconnection by the server and set the state of the AprsIsConnection to disconnected to match.

Changes

  • Pipe through TcpClient.Connected check to ITcpConnection and TcpConnection
  • Add a check against ITcpConnection.Connected in the receive loop in AprsIsConnection
  • Add a new test
  • Update existing tests

Validation

  • New test covering the disconnection scenario
  • Build and tests pass

@CBielstein CBielstein added the bug Something isn't working label Apr 22, 2022
@CBielstein CBielstein self-assigned this Apr 22, 2022
@CBielstein CBielstein merged commit 04c0271 into main Apr 26, 2022
@CBielstein CBielstein deleted the tcp-disconnect branch April 26, 2022 03:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant