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

Read Timeout Error #364

Closed
sochix opened this Issue Aug 3, 2016 · 12 comments

Comments

Projects
None yet
10 participants
@sochix

sochix commented Aug 3, 2016

Steps to reproduce

  1. Add several jobs to a queue, which will wait >15 mins and then send message
  2. Wait till message will send
  3. Get an ReadTimeoutError

Expected behaviour

Should send a message

Actual behaviour

Get ReadTimeoutException:

urllib3.connectionpool - WARNING - Retrying (Retry(total=2, connect=None, read=None, redirect=None)) after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='api.telegram.org', port=443): Read timed out. (read timeout=<object object at 0x7f8986fae080>)",)': 

Configuration

Operating System:
Ubuntu 16.04 LTS

Version of Python, python-telegram-bot & dependencies:

$ python -m telegram
python-telegram-bot 5.0.0
urllib3 1.16
certifi 2016.08.02
future 0.15.2
Python 3.4.3 (default, Oct 14 2015, 20:28:29)  [GCC 4.8.4]
@RenathoAzevedo

This comment has been minimized.

RenathoAzevedo commented Sep 16, 2016

I'm getting the same error, The api works great at sometimes, but , in others the bot don't answer, and the warning is being thrown. may someone help me ?

2016-09-16 10:29:14,701 - telegram.bot - DEBUG - Getting updates: [300247182]
2016-09-16 10:29:14,701 - telegram.bot - DEBUG - [<telegram.update.Update object at 0x7f113c6d3b00>]
2016-09-16 10:29:14,702 - telegram.bot - DEBUG - Exiting: getUpdates
2016-09-16 10:29:14,702 - telegram.bot - DEBUG - Entering: getUpdates
2016-09-16 10:29:25,003 - telegram.bot - DEBUG - No new updates found.
2016-09-16 10:29:25,003 - telegram.bot - DEBUG - []
2016-09-16 10:34:46,972 - urllib3.connectionpool - WARNING - Retrying (Retry(total=2, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f113df74588>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution',)': /botTOKEN/getUpdates

@jh0ker jh0ker added the question label Sep 20, 2016

@jh0ker

This comment has been minimized.

Member

jh0ker commented Sep 20, 2016

@sochix Could you please post a minimal working example so we can reproduce?

@RenathoAzevedo Your error is a different than @sochix is getting (ReadTimeoutError vs. NewConnectionError). You can file a new issue for it. But it looks to me as if your host had connection issues, and there is nothing we can do for you in that case.

@RenathoAzevedo

This comment has been minimized.

RenathoAzevedo commented Sep 20, 2016

@jh0ker I didn't realize that the program gave me a different error until now, but I tested it now, and it throws the same error that I was getting:

urllib3.connectionpool - WARNING - Retrying (Retry(total=2, connect=None, read=None, redirect=None)) after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='api.telegram.org', port=443): Read timed out. (read timeout=<object object at 0x7f065f1aa0c0>)",)': /botTOKEN/sendMessage

I don't know why I got a different error when I posted it, I didn't even checked the log, just copied and pasted, sorry. But the problem is the same, the program runs fine as I expected, but in one hour or less, when I send a command to my bot, it simply doesn't answer me, after fifteen or twenty minutes the answer comes and this error above also comes up . Any idea about what is happening? The program that I'm using is a modified provided example to send me photo and documents by writing the file name/path.

@funn

This comment has been minimized.

funn commented Dec 8, 2016

Got the same error with my bot. If I wait more than 15 minutes and then try to send a message to chat first message wont be delivered right away, though all the following messages are sent just fine, no matter how much and how frequent:

2016-12-07 18:33:58,645 - telegram.bot - DEBUG - Entering: sendMessage
2016-12-07 18:33:59,965 - telegram.bot - DEBUG - No new updates found.
2016-12-07 18:33:59,966 - telegram.bot - DEBUG - []
2016-12-07 18:33:59,966 - telegram.bot - DEBUG - Exiting: getUpdates
2016-12-07 18:33:59,966 - telegram.bot - DEBUG - Entering: getUpdates
2016-12-07 18:34:10,185 - telegram.bot - DEBUG - No new updates found.
2016-12-07 18:34:10,185 - telegram.bot - DEBUG - []
2016-12-07 18:34:10,185 - telegram.bot - DEBUG - Exiting: getUpdates

Bot will enter message sending, as seen in the first line, then it will start spitting warnings after some time:

2016-12-07 18:51:21,231 - urllib3.connectionpool - WARNING - Connection pool is full, discarding connection: api.telegram.org
2016-12-07 18:51:21,231 - urllib3.connectionpool - WARNING - Retrying (Retry(total=2, connect=None, read=None, redirect=None)) after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='api.telegram.org', port=443): Read timed out. (read timeout=<object object at 0x7f92bf6261a0>)",)': /botMY_SUPER_SECRET_TOKEN/sendMessage

And after some time, finally it sends it:

2016-12-07 19:06:49,657 - urllib3.connectionpool - WARNING - Retrying (Retry(total=1, connect=None, read=None, redirect=None)) after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='api.telegram.org', port=443): Read timed out. (read timeout=<object object at 0x7f92bf6261a0>)",)': /botMY_SUPER_SECRET_TOKEN/sendMessage
2016-12-07 19:06:50,307 - telegram.bot - DEBUG - {'new_chat_title': '', 'delete_chat_photo': False, 'text': 'ayyy lmao', 'from': {'last_name': '', 'username': 'SiberianNinjaBot', 'type': '', 'first_name': 'Siberian Ninja Bot', 'id': 236012339}, 'new_chat_photo': [], 'date': 1481137610, 'chat': {'last_name': '', 'title': 'tg67', 'first_name': '', 'type': 'group', 'username': '', 'all_members_are_admins': False, 'id': -196998530}, 'caption': '', 'entities': [], 'migrate_from_chat_id': 0, 'migrate_to_chat_id': 0, 'group_chat_created': False, 'channel_chat_created': False, 'photo': [], 'supergroup_chat_created': False, 'message_id': 483}
2016-12-07 19:06:50,307 - telegram.bot - DEBUG - Exiting: sendMessage

@gregsonar

This comment has been minimized.

gregsonar commented Dec 15, 2016

Im getting same erron using python-telegram bot.
2016-12-15 09:26:32,684 - urllib3.connectionpool - WARNING - Retrying (Retry(total=2, connect=None, read=None, redirect=None)) after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='api.telegram.org', port=443): Read timed out. (read timeout=15.0)",)': /bot<TOKEN>/getUpdates
The error does not significantly affect the work of the bot (possibly in my case, with a small number of users), but it regularly appears in the console.
Does anyone know how to get rid of this error?

@blueset

This comment has been minimized.

blueset commented Dec 21, 2016

Same problem here. This is causing some messages delays for 30 mins in average.

tsnoam added a commit that referenced this issue Jan 6, 2017

@tsnoam

This comment has been minimized.

Member

tsnoam commented Jan 6, 2017

FYI, PR #499 is now under review.

tsnoam added a commit that referenced this issue Jan 7, 2017

tsnoam added a commit that referenced this issue Jan 7, 2017

tsnoam added a commit that referenced this issue Jan 7, 2017

tsnoam added a commit that referenced this issue Jan 7, 2017

@tsnoam

This comment has been minimized.

Member

tsnoam commented Jan 7, 2017

Hi,
New code is currently on the master branch. While we're preparing for v6 release, you're invited to test the master branch and reopen this case if needed.

@tsnoam tsnoam closed this Jan 7, 2017

@tsnoam

This comment has been minimized.

Member

tsnoam commented Jan 8, 2017

@iota-sigma-pi thanks for the feedback. :-)

@DavidVentura

This comment has been minimized.

DavidVentura commented May 18, 2017

I'm still getting this:

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.5/threading.py", line 914, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.5/threading.py", line 862, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/local/lib/python3.5/dist-packages/telegram/ext/updater.py", line 115, in _thread_wrapper
    target(*args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/telegram/ext/updater.py", line 233, in _start_polling
    self.last_update_id, timeout=timeout, network_delay=network_delay)
  File "/usr/local/lib/python3.5/dist-packages/telegram/bot.py", line 125, in decorator
    result = func(self, *args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/telegram/bot.py", line 1241, in getUpdates
    result = self._request.post(url, data, timeout=urlopen_timeout)
  File "/usr/local/lib/python3.5/dist-packages/telegram/utils/request.py", line 207, in post
    **urlopen_kwargs)
  File "/usr/local/lib/python3.5/dist-packages/telegram/utils/request.py", line 132, in _request_wrapper
    resp = self._con_pool.request(*args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/urllib3/request.py", line 70, in request
    **urlopen_kw)
  File "/usr/local/lib/python3.5/dist-packages/urllib3/request.py", line 148, in request_encode_body
    return self.urlopen(method, url, **extra_kw)
  File "/usr/local/lib/python3.5/dist-packages/urllib3/poolmanager.py", line 244, in urlopen
    response = conn.urlopen(method, u.request_uri, **kw)
  File "/usr/local/lib/python3.5/dist-packages/urllib3/connectionpool.py", line 649, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/usr/local/lib/python3.5/dist-packages/urllib3/util/retry.py", line 347, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "/usr/local/lib/python3.5/dist-packages/urllib3/packages/six.py", line 686, in reraise
    raise value
  File "/usr/local/lib/python3.5/dist-packages/urllib3/connectionpool.py", line 600, in urlopen
    chunked=chunked)
  File "/usr/local/lib/python3.5/dist-packages/urllib3/connectionpool.py", line 388, in _make_request
    self._raise_timeout(err=e, url=url, timeout_value=read_timeout)
  File "/usr/local/lib/python3.5/dist-packages/urllib3/connectionpool.py", line 308, in _raise_timeout
    raise ReadTimeoutError(self, url, "Read timed out. (read timeout=%s)" % timeout_value)
urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='api.telegram.org', port=443): Read timed out. (read timeout=15.0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.5/threading.py", line 914, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.5/threading.py", line 862, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/local/lib/python3.5/dist-packages/telegram/ext/updater.py", line 115, in _thread_wrapper
    target(*args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/telegram/ext/updater.py", line 233, in _start_polling
    self.last_update_id, timeout=timeout, network_delay=network_delay)
  File "/usr/local/lib/python3.5/dist-packages/telegram/bot.py", line 125, in decorator
    result = func(self, *args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/telegram/bot.py", line 1241, in getUpdates
    result = self._request.post(url, data, timeout=urlopen_timeout)
  File "/usr/local/lib/python3.5/dist-packages/telegram/utils/request.py", line 207, in post
    **urlopen_kwargs)
  File "/usr/local/lib/python3.5/dist-packages/telegram/utils/request.py", line 132, in _request_wrapper
    resp = self._con_pool.request(*args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/urllib3/request.py", line 70, in request
    **urlopen_kw)
  File "/usr/local/lib/python3.5/dist-packages/urllib3/request.py", line 148, in request_encode_body
    return self.urlopen(method, url, **extra_kw)
  File "/usr/local/lib/python3.5/dist-packages/urllib3/poolmanager.py", line 244, in urlopen
    response = conn.urlopen(method, u.request_uri, **kw)
  File "/usr/local/lib/python3.5/dist-packages/urllib3/connectionpool.py", line 649, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/usr/local/lib/python3.5/dist-packages/urllib3/util/retry.py", line 347, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "/usr/local/lib/python3.5/dist-packages/urllib3/packages/six.py", line 686, in reraise
    raise value
  File "/usr/local/lib/python3.5/dist-packages/urllib3/connectionpool.py", line 600, in urlopen
    chunked=chunked)
  File "/usr/local/lib/python3.5/dist-packages/urllib3/connectionpool.py", line 388, in _make_request
    self._raise_timeout(err=e, url=url, timeout_value=read_timeout)
  File "/usr/local/lib/python3.5/dist-packages/urllib3/connectionpool.py", line 308, in _raise_timeout
    raise ReadTimeoutError(self, url, "Read timed out. (read timeout=%s)" % timeout_value)
urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='api.telegram.org', port=443): Read timed out. (read timeout=15.0)
@levzhazeschi

This comment has been minimized.

levzhazeschi commented Aug 16, 2017

I have the same problem. Is there a solution?

@jsmnbom

This comment has been minimized.

Member

jsmnbom commented Aug 16, 2017

Please create a new issue with the template filled out.... It's probably not the same issue after all.

@python-telegram-bot python-telegram-bot locked and limited conversation to collaborators Aug 16, 2017

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.