python-slack-sdk icon indicating copy to clipboard operation
python-slack-sdk copied to clipboard

Random timeout errors when calling views_publish

Open iamarora opened this issue 6 years ago • 8 comments

Description

Recently started seeing random timeout errors while calling views_publish on webclient. Everything was fine until a few days ago. I checked with the slack support team as I suspected something to do with the API, they were not able to replicate the same with the API and suggested that I raise the issue here as I was using the python client.

What type of issue is this? (place an x in one of the [ ])

  • [x] bug
  • [ ] enhancement (feature request)
  • [ ] question
  • [ ] documentation related
  • [ ] testing related
  • [ ] discussion

Requirements (place an x in each of the [ ])

  • [x] I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • [x] I've read and agree to the Code of Conduct.
  • [x] I've searched for any related issues and avoided creating a duplicate issue.

Bug Report

Filling out the following details about bugs will help us solve your issue sooner.

Reproducible in:

slackclient version: slackclient==2.5.0 python version: python 3.7 OS version(s): Ubuntu

Steps to reproduce:

  1. Call this views_publish on a json with about ~30 blocks close to 10 times at least one of them fails with a timeout. Sample code
import slack
bot_oauth_token = ''  # Add valid bot_token
client = slack.WebClient(token=bot_oauth_token)
j = {}  # A valid slack user_id and view with type as home and blocks.
client.views_publish(**j)

Expected result:

No request should fail with a timeout

Actual result:

Timeout exception, stack trace below

  File "/home/ankit/.virtualenvs/son-of-anton/lib/python3.6/site-packages/slack/web/client.py", line 1741, in views_publish
    return self.api_call("views.publish", json=kwargs)
  File "/home/ankit/.virtualenvs/son-of-anton/lib/python3.6/site-packages/slack/web/base_client.py", line 171, in api_call
    return self._event_loop.run_until_complete(future)
  File "/usr/lib/python3.6/asyncio/base_events.py", line 484, in run_until_complete
    return future.result()
  File "/home/ankit/.virtualenvs/son-of-anton/lib/python3.6/site-packages/slack/web/base_client.py", line 214, in _send
    http_verb=http_verb, api_url=api_url, req_args=req_args
  File "/home/ankit/.virtualenvs/son-of-anton/lib/python3.6/site-packages/slack/web/base_client.py", line 244, in _request
    async with session.request(http_verb, api_url, **req_args) as res:
  File "/home/ankit/.virtualenvs/son-of-anton/lib/python3.6/site-packages/aiohttp/client.py", line 1012, in __aenter__
    self._resp = await self._coro
  File "/home/ankit/.virtualenvs/son-of-anton/lib/python3.6/site-packages/aiohttp/client.py", line 504, in _request
    await resp.start(conn)
  File "/home/ankit/.virtualenvs/son-of-anton/lib/python3.6/site-packages/aiohttp/client_reqrep.py", line 860, in start
    self._continue = None
  File "/home/ankit/.virtualenvs/son-of-anton/lib/python3.6/site-packages/aiohttp/helpers.py", line 596, in __exit__
    raise asyncio.TimeoutError from None
concurrent.futures._base.TimeoutError
Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x7f872a502828>

iamarora avatar Jul 27 '20 17:07 iamarora

slackclient version: slackclient==2.5.0

Could you try the latest version - v.2.7.3 out? Although we had similar issues particularly with old versions (older than 2.6), the latest version should not have this issue.

seratch avatar Jul 27 '20 21:07 seratch

Thanks for the quick response. I upgraded the slackclient on my local and ran my snippet 10 times and got no timeout. :) I'm upgrading the version on my production and will keep an eye out there as well, should get to know the results of that within a day as I was getting frequent timeouts there as well. Will post here once resolved. Thanks!

iamarora avatar Jul 28 '20 05:07 iamarora

So, I did get a few more timeouts on my production after making sure the updated packages were being used on production. I tried to replicate this on my local with a test workspace and got the below stacktrace. Ran about 10 requests all of them succeeded in ~1 second but one of them timed out in 30 seconds.

Any other recommendations?

client.views_publish(**j)
  File "/home/ankit/.virtualenvs/kaapi_test/lib/python3.7/site-packages/slack/web/client.py", line 2098, in views_publish
    return self.api_call("views.publish", json=kwargs)
  File "/home/ankit/.virtualenvs/kaapi_test/lib/python3.7/site-packages/slack/web/base_client.py", line 215, in api_call
    return self._sync_send(api_url=api_url, req_args=req_args)
  File "/home/ankit/.virtualenvs/kaapi_test/lib/python3.7/site-packages/slack/web/base_client.py", line 357, in _sync_send
    additional_headers=headers,
  File "/home/ankit/.virtualenvs/kaapi_test/lib/python3.7/site-packages/slack/web/base_client.py", line 461, in _urllib_api_call
    response = self._perform_urllib_http_request(url=url, args=request_args)
  File "/home/ankit/.virtualenvs/kaapi_test/lib/python3.7/site-packages/slack/web/base_client.py", line 596, in _perform_urllib_http_request
    raise err
  File "/home/ankit/.virtualenvs/kaapi_test/lib/python3.7/site-packages/slack/web/base_client.py", line 577, in _perform_urllib_http_request
    req, context=self.ssl, timeout=self.timeout
  File "/home/linuxbrew/.linuxbrew/opt/python/lib/python3.7/urllib/request.py", line 222, in urlopen
    return opener.open(url, data, timeout)
  File "/home/linuxbrew/.linuxbrew/opt/python/lib/python3.7/urllib/request.py", line 525, in open
    response = self._open(req, data)
  File "/home/linuxbrew/.linuxbrew/opt/python/lib/python3.7/urllib/request.py", line 543, in _open
    '_open', req)
  File "/home/linuxbrew/.linuxbrew/opt/python/lib/python3.7/urllib/request.py", line 503, in _call_chain
    result = func(*args)
  File "/home/linuxbrew/.linuxbrew/opt/python/lib/python3.7/urllib/request.py", line 1362, in https_open
    context=self._context, check_hostname=self._check_hostname)
  File "/home/linuxbrew/.linuxbrew/opt/python/lib/python3.7/urllib/request.py", line 1322, in do_open
    r = h.getresponse()
  File "/home/linuxbrew/.linuxbrew/opt/python/lib/python3.7/http/client.py", line 1344, in getresponse
    response.begin()
  File "/home/linuxbrew/.linuxbrew/opt/python/lib/python3.7/http/client.py", line 306, in begin
    version, status, reason = self._read_status()
  File "/home/linuxbrew/.linuxbrew/opt/python/lib/python3.7/http/client.py", line 267, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  File "/home/linuxbrew/.linuxbrew/opt/python/lib/python3.7/socket.py", line 589, in readinto
    return self._sock.recv_into(b)
  File "/home/linuxbrew/.linuxbrew/opt/python/lib/python3.7/ssl.py", line 1071, in recv_into
    return self.read(nbytes, buffer)
  File "/home/linuxbrew/.linuxbrew/opt/python/lib/python3.7/ssl.py", line 929, in read
    return self._sslobj.read(len, buffer)
socket.timeout: The read operation timed out

real	0m30.305s
user	0m0.197s
sys	0m0.042s

iamarora avatar Jul 28 '20 07:07 iamarora

Something very similar (same errors appearing randomly) happening here, version 2.7.3

laurikoobas avatar Jul 31 '20 13:07 laurikoobas

@iamarora @laurikoobas

The server-side has been having an issue with some of the APIs for a few days. You may be affected by the issue. We're sorry for the inconvenience.

We're currently aware of some intermittent latency and timeouts with image attachments, certain API methods (including users.setPhoto, chat.postMessage and chat.update, views.*), and apps which use these features. We are currently investigating and will update when we believe these issues have been resolved. Sorry for the inconvenience.

https://status.slack.com/2020-07/7d32ad54b0703c47

seratch avatar Jul 31 '20 13:07 seratch

The incident has been resolved and we have not been observing this issue after that. Please let me close this issue after waiting for further comments for a few weeks.

seratch avatar Aug 12 '20 07:08 seratch

Yes, thank you, you can close this issue.

iamarora avatar Aug 12 '20 07:08 iamarora

Thanks for confirming this! I believe we can safely close this issue now.

seratch avatar Aug 20 '20 01:08 seratch