Skip to content
This repository has been archived by the owner on Jul 3, 2020. It is now read-only.

exceptions.ReadTimeout gets raised even though the message goes through #132

Open
mikhaildubov opened this issue May 10, 2018 · 2 comments

Comments

@mikhaildubov
Copy link

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
Copy link
Owner

os commented May 11, 2018

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
Copy link

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>
...

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants