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

Update TCPClient to detect and handle TCP socket closures. #100

Closed

Conversation

brandondahler
Copy link

Fixes #99

Description of changes:
Updates TCPClient to do a single-byte, non-blocking read after making a write to make a best effort to detect when our write might have been made to a closed socket.

  • TCP sockets won't usually throw a pipe broken exception until a non-empty read request is executed against it.
  • Had to switch to using SocketChannel in order to be able to do a non-blocking read.
  • Chose to do the read after the write attempt because that ensures that this write was actually sent instead of potentially silently failing.
  • It is technically possible for a metric to be double-sent if there is a race between the write and read.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@brandondahler
Copy link
Author

See #108, further testing shows that this doesn't resolve the reported issue.

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.

TCP socket poisoned by agent restart
1 participant