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

Reconnect flow does not check for dead sockets #142

Closed
george-unbotify opened this issue Jul 21, 2018 · 4 comments
Closed

Reconnect flow does not check for dead sockets #142

george-unbotify opened this issue Jul 21, 2018 · 4 comments

Comments

@george-unbotify
Copy link

It seems that reconnect() only checks if socket exists and does not check for disconnected sockets.

To reproduce the issue:

  1. Run a python fluentd client and a fluentd service
  2. Send data from client to fluentd
  3. Restart fluentd while keeping client running
  4. Try to send data again to fluentd using same client

Step 4 fails due to a connection reset by peer error.

@arcivanov
Copy link
Member

You cannot check if the connection is valid or invalid. Once the socket is determined to back a broken connection by an act of sending data and reading back a response, the socket will be closed, reference set to None and and a new socket will be created on the next reconnect.

@george-unbotify
Copy link
Author

You can try to handle connection errors with some sort of a retry.
If not - at least add a documentation stating recommending the user to add a retry mechanism in case the socket is dead.

@arcivanov
Copy link
Member

arcivanov commented Jul 22, 2018

@george-unbotify Retries are not possible without server-based ACK which is a separate issue #120 altogether. Without ACK, there is no possibility, even in theory to know whether the socket is dead unless the router actively sends ICMP to indicate the connection has been broken or kernel detects it by other means. This is a fundamental limitation of the TCP protocol and has been there since 1974.

If the socket errors out, the reconnect is called automatically after the socket reference it's cleared.

Reconnect on every send if necessary:

Close and reset socket if any error occurred and was detected:

@arcivanov
Copy link
Member

Furthermore, even in theory, a user cannot add a retry mechanism of any kind with any degree of reliability without server-side ack.

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

No branches or pull requests

2 participants