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

Remote Close Connection in get_updates() #30

Closed
Gameheld opened this issue Nov 17, 2022 · 3 comments · Fixed by #32
Closed

Remote Close Connection in get_updates() #30

Gameheld opened this issue Nov 17, 2022 · 3 comments · Fixed by #32

Comments

@Gameheld
Copy link

Hello,
My Bot stops to listen for messages after an amount of time due to a Remote Close Connection. It seems to happen in /core/api_request.py Autoposting or other actions stated in the main thread still work as expected.
This is my log:

*** | Exception while polling
*** | Traceback (most recent call last):
*** |   File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 703, in urlopen
*** |     httplib_response = self._make_request(
*** |   File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 449, in _make_request
*** |     six.raise_from(e, None)
*** |   File "<string>", line 3, in raise_from
*** |   File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 444, in _make_request
*** |     httplib_response = conn.getresponse()
*** |   File "/usr/local/lib/python3.10/http/client.py", line 1374, in getresponse
*** |     response.begin()
*** |   File "/usr/local/lib/python3.10/http/client.py", line 318, in begin
*** |     version, status, reason = self._read_status()
*** |   File "/usr/local/lib/python3.10/http/client.py", line 287, in _read_status
*** |     raise RemoteDisconnected("Remote end closed connection without"
*** | http.client.RemoteDisconnected: Remote end closed connection without response
*** |
*** | During handling of the above exception, another exception occurred:
*** |
*** | Traceback (most recent call last):
*** |   File "/usr/local/lib/python3.10/site-packages/requests/adapters.py", line 489, in send
*** |     resp = conn.urlopen(
*** |   File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 787, in urlopen
*** |     retries = retries.increment(
*** |   File "/usr/local/lib/python3.10/site-packages/urllib3/util/retry.py", line 550, in increment
*** |     raise six.reraise(type(error), error, _stacktrace)
*** |   File "/usr/local/lib/python3.10/site-packages/urllib3/packages/six.py", line 769, in reraise
*** |     raise value.with_traceback(tb)
*** |   File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 703, in urlopen
*** |     httplib_response = self._make_request(
*** |   File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 449, in _make_request
*** |     six.raise_from(e, None)
*** |   File "<string>", line 3, in raise_from
*** |   File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 444, in _make_request
*** |     httplib_response = conn.getresponse()
*** |   File "/usr/local/lib/python3.10/http/client.py", line 1374, in getresponse
*** |     response.begin()
*** | During handling of the above exception, another exception occurred:
*** |
*** | Traceback (most recent call last):
*** |   File "/usr/local/lib/python3.10/site-packages/origamibot/core/bot.py", line 1440, in _listen_loop
*** |     updates = self.get_updates()
*** |   File "/usr/local/lib/python3.10/site-packages/origamibot/core/bot.py", line 313, in get_updates
*** |     updates = get_updates(
*** |   File "/usr/local/lib/python3.10/site-packages/origamibot/core/api_request.py", line 109, in get_updates
*** |     updates = request(
*** |   File "/usr/local/lib/python3.10/site-packages/origamibot/core/api_request.py", line 86, in request
*** |     response = requests.post(url, data=json_data, headers=headers)
*** |   File "/usr/local/lib/python3.10/site-packages/requests/api.py", line 115, in post
*** |     return request("post", url, data=data, json=json, **kwargs)
*** |   File "/usr/local/lib/python3.10/site-packages/requests/api.py", line 59, in request
*** |     return session.request(method=method, url=url, **kwargs)
*** |   File "/usr/local/lib/python3.10/site-packages/requests/sessions.py", line 587, in request
*** |     resp = self.send(prep, **send_kwargs)
*** |   File "/usr/local/lib/python3.10/site-packages/requests/sessions.py", line 701, in send
*** |     r = adapter.send(request, **kwargs)
*** |   File "/usr/local/lib/python3.10/site-packages/requests/adapters.py", line 547, in send
*** |     raise ConnectionError(err, request=request)
*** | requests.exceptions.ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection
without response'))
@cmd410
Copy link
Owner

cmd410 commented Nov 17, 2022

This seems to be network related error. Do you have any kind of PoC to reliably reproduce this?

@Gameheld
Copy link
Author

I restarted the bot 2 days ago and the bot stopped reacting to my commands yesterday. The daily announcement at 23:59 worked without problems. The server on which the is running had no downtime. The error log shows the following:

***    | Exception in thread Listen thread:
***    | Traceback (most recent call last):
***    |   File "/usr/local/lib/python3.10/threading.py", line 1016, in _bootstrap_inner
***    |     self.run()
***    |   File "/usr/local/lib/python3.10/threading.py", line 953, in run
***    |     self._target(*self._args, **self._kwargs)
***    |   File "/usr/local/lib/python3.10/site-packages/origamibot/core/bot.py", line 1440, in _listen_loop
***    |     updates = self.get_updates()
***    |   File "/usr/local/lib/python3.10/site-packages/origamibot/core/bot.py", line 313, in get_updates
***    |     updates = get_updates(
***    |   File "/usr/local/lib/python3.10/site-packages/origamibot/core/api_request.py", line 109, in get_updates
***    |     updates = request(
***    |   File "/usr/local/lib/python3.10/site-packages/origamibot/core/api_request.py", line 91, in request
***    |     raise TelegramAPIError(f'[{response.status_code}] {description}')
***    | origamibot.core.exceptions.TelegramAPIError: [429] Too Many Requests: retry after 5

@vakdevi
Copy link

vakdevi commented Dec 12, 2022

Hello. I got the same exception in the listen thread after about 5 minutes.
Problem is there is no way to catch this exception and deal with it in the user application (and the bot being toast).

Exception in thread Listen thread:
Traceback (most recent call last):
  File "/usr/lib/python3.10/threading.py", line 1009, in _bootstrap_inner
    self.run()% 
  File "/usr/lib/python3.10/threading.py", line 946, in run
    self._target(*self._args, **self._kwargs)
  File "/home/pi/.local/lib/python3.10/site-packages/origamibot/core/bot.py", line 1440, in _listen_loop
    updates = self.get_updates()
  File "/home/pi/.local/lib/python3.10/site-packages/origamibot/core/bot.py", line 313, in get_updates
    updates = get_updates(
  File "/home/pi/.local/lib/python3.10/site-packages/origamibot/core/api_request.py", line 109, in get_updates
    updates = request(
  File "/home/pi/.local/lib/python3.10/site-packages/origamibot/core/api_request.py", line 91, in request
    raise TelegramAPIError(f'[{response.status_code}] {description}')
origamibot.core.exceptions.TelegramAPIError: [429] Too Many Requests: retry after 5

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 a pull request may close this issue.

3 participants