Skip to content

RTMClient does not pass timeout value to WebClient #846

@Luden

Description

@Luden

Reproducible in:

python 3.8.2
slackclient 2.9.2

The Slack SDK version

slackclient 2.9.2

Python runtime version

python 3.8.2

OS info

Microsoft Windows [Version 10.0.19041.572]

and

ProductName: Mac OS X
ProductVersion: 10.15.4
BuildVersion: 19E287
Darwin Kernel Version 19.4.0: Wed Mar 4 22:28:40 PST 2020; root:xnu-6153.101.6~15/RELEASE_X86_64

Steps to reproduce:

  1. create an RTM client with custom timeout
rtm_client = RTMClient(token=slack_client.token, timeout=300)
  1. try to upload large file with slow connection so it will take more than 30s, which is default timeout

in my case, as a callback of

self.rtm_client.on(event='message', callback=self.rtm_client_run_on)

use

def rtm_client_run_on(self, *args, **payload):`
    web_client = payload['web_client']`
    web_client.files_upload(channels=message_context.channel, file=file_path, filename=file_name_display)`

Expected result:

file will upload, no exceptions

Actual result:

timeout error

`Traceback (most recent call last):`
` File "/Volumes/X5/survival_bot/Util/westland_bot/slack_bot.py", line 40, in rtm_client_run_on`
`   self.process_bots(web_client, sender, data['text'], channel, is_group_channel)`
` File "/Volumes/X5/survival_bot/Util/westland_bot/slack_bot.py", line 82, in process_bots`
`   web_client.files_upload(`
` File "/usr/local/lib/python3.8/site-packages/slack/web/client.py", line 1533, in files_upload`
`   return self.api_call("files.upload", files={"file": file}, data=kwargs)`
` File "/usr/local/lib/python3.8/site-packages/slack/web/base_client.py", line 150, in api_call`
`   return self._sync_send(api_url=api_url, req_args=req_args)`
` File "/usr/local/lib/python3.8/site-packages/slack/web/base_client.py", line 241, in _sync_send`
`   return self._urllib_api_call(`
` File "/usr/local/lib/python3.8/site-packages/slack/web/base_client.py", line 352, in _urllib_api_call`
`   response = self._perform_urllib_http_request(url=url, args=request_args)`
` File "/usr/local/lib/python3.8/site-packages/slack/web/base_client.py", line 495, in _perform_urllib_http_request`
`   raise err`
` File "/usr/local/lib/python3.8/site-packages/slack/web/base_client.py", line 475, in _perform_urllib_http_request`
`   resp = urlopen(  # skipcq: BAN-B310`
` File "/usr/local/Cellar/python@3.8/3.8.5/Frameworks/Python.framework/Versions/3.8/lib/python3.8/urllib/request.py", line 222, in urlopen`
`   return opener.open(url, data, timeout)`
` File "/usr/local/Cellar/python@3.8/3.8.5/Frameworks/Python.framework/Versions/3.8/lib/python3.8/urllib/request.py", line 525, in open`
`   response = self._open(req, data)`
` File "/usr/local/Cellar/python@3.8/3.8.5/Frameworks/Python.framework/Versions/3.8/lib/python3.8/urllib/request.py", line 542, in _open`
`   result = self._call_chain(self.handle_open, protocol, protocol +`
` File "/usr/local/Cellar/python@3.8/3.8.5/Frameworks/Python.framework/Versions/3.8/lib/python3.8/urllib/request.py", line 502, in _call_chain`
`   result = func(*args)`
` File "/usr/local/Cellar/python@3.8/3.8.5/Frameworks/Python.framework/Versions/3.8/lib/python3.8/urllib/request.py", line 1393, in https_open`
`   return self.do_open(http.client.HTTPSConnection, req,`
` File "/usr/local/Cellar/python@3.8/3.8.5/Frameworks/Python.framework/Versions/3.8/lib/python3.8/urllib/request.py", line 1353, in do_open`
`18:36`
`raise URLError(err)`
`urllib.error.URLError: <urlopen error The write operation timed out>`

Why this happened

RTMClient is it's __init__ does not pass timeout to _web_client
file rtm\client.py line 136

Workaround

assing timeout manually after creation of RTMClient

rtm_client = RTMClient(token=slack_client.token, timeout=300)
rtm_client._web_client.timeout = 300

Metadata

Metadata

Assignees

No one assigned

    Labels

    Version: 2xbugM-T: A confirmed bug report. Issues are confirmed when the reproduction steps are documentedrtm-client

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions