slacker icon indicating copy to clipboard operation
slacker copied to clipboard

exceptions.ReadTimeout gets raised even though the message goes through

Open mikhaildubov opened this issue 6 years ago • 2 comments

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.

mikhaildubov avatar May 10 '18 14:05 mikhaildubov

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?

os avatar May 11 '18 00:05 os

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

brentwatson avatar May 29 '18 14:05 brentwatson