exceptions.ReadTimeout gets raised even though the message goes through
mikhaildubov opened this issue · 2 comments
mikhaildubov commented
As described here in much detail, Slacker has recently started throwing lots of exceptions.ReadTimeout
errors even when the message goes through just fine:
File "/root/.homeassistant/deps/lib/python3.5/site-packages/slacker/__init__.py", line 123, in post
api, **kwargs
File "/root/.homeassistant/deps/lib/python3.5/site-packages/slacker/__init__.py", line 94, in _request
**kwargs)
File "/usr/local/lib/python3.5/dist-packages/requests/api.py", line 112, in post
return request('post', url, data=data, json=json, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/requests/api.py", line 58, in request
return session.request(method=method, url=url, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/requests/sessions.py", line 508, in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/lib/python3.5/dist-packages/requests/sessions.py", line 618, in send
r = adapter.send(request, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/requests/adapters.py", line 521, in send
raise ReadTimeout(e, request=request)
requests.exceptions.ReadTimeout: HTTPSConnectionPool(host='slack.com', port=443): Read timed out. (read timeout=10)
Facing the same issue in one of my projects at the moment so reporting it here.
os commented
It doesn't look like it's related with Slacker - the exception is being raised in requests
level. I would say it's either requests
or Slack API itself. What's your slacker
and requests
versions? Is this something you started to experience after an upgrade or?
brentwatson commented
I encountered the same issue and this seems to have resolved it for me:
from urllib3.util.retry import Retry
from requests.adapters import HTTPAdapter
...
retries = Retry(connect=5, read=3, redirect=3)
http_session = requests.Session()
http_session.mount('https://<yourdomain>.slack.com', HTTPAdapter(max_retries=retries))
...
<make your slack requests>
...