-
-
Notifications
You must be signed in to change notification settings - Fork 116
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
Reusing too old connection (ECONNRESET) #172
Comments
Hm that sounds reaaonable. Do you think that I should reconnect from time to time? |
I just had a look at the code and realized that connection management is not actually done here but in the telegram-bot-api you're using. So we shouldn't actually try to solve it here, but instead I'll open an issue at the upstream repository. If you want to work around it (which we should avoid as long as there is a chance it's fixed upstream), you may remember when the last message was sent and if it's been too long when the next message comes in, do a reconnect before sending. |
I fully agree. Do you have any idea how long „too long“ could be? Is it minutes, hours or days? |
That's hard to say, because it depends on how long the Telegram servers will remember the connection. The default idle timeout for TCP connections is 300 seconds. |
Yes but 300seconds is way too low. Btw did you check if the header of a somgle message contains some sort of token or authentication id? Maybe that one needs to be renewed? |
The payload is encrypted (TLS), so I do not know if there is some internal Telegram connection ID. But: Whenever the connection reset happens, all three connections have stopped transmitting data for something like 10 minutes or longer, sometimes hours. So I guess something somewhere went wrong and the polling stopped. Then, after a while, the Telegram server closes the connection, because they idled for too long. So, if you want to improve things on your side, you need to find some way to test if polling is still working and if it didn't work for too long (e.g. 300 s), trigger a reconnect. I guess the sending message problem would be fixed by that then, too. |
There is actually something about taking care about polling errors: But I think you're doing that already, from what I can see. But I cannot see the appropriate warning in the logs, so I guess something it's quite right there. |
If the connection is reset, what is written to the log? Can you paste it here? |
Yes I can. Unfortunately the answer is: ""
Not particularly helpful either. |
Ah ok, then I guess it would be best to intercept that error in one of the sender nodes ... the only problem would be that the message is lost as we detected the problem after the attempt was made. Maybe it would be best to find out if the connection still works before sending something... |
I think the best approach would be to find out why we don't notice the lost connection seconds after if happens and instead just sit there disconnected until randomly a message arrives to be send. Probably if we reconnect when that happens, the problems of sending messages will go away by itself. |
Version 10.0.3 will recreate the polling class. I hope that this helps to reestablish the connection somehow. Please test it and let me know. You may reopen the issue if the problem still exists. |
Hello again. |
A while ago I noticed that messages were randomly not send out to Telegram, the error message is ECONNRESET.
I traced the problem with tcpdump and found the following sequence of events:
So I guess the problem is that telegrambot tries to reuse a connection that may be hours old and which has been forgotten by the server for ages.
Either this needs to be changed to always (or at least if the old connection is too old) making a new connection or alternatively, sending must be retried at least one time after ECONNRESET.
The text was updated successfully, but these errors were encountered: