Skip to content

RTMClient.start fails when enabling proxy with Python 3.8.2 + Windows OS #642

Description

@Allexio

Description

Hi, I've been running a slack bot for about six months with no issues.
About two months ago, I upgraded my bot to slackclient 2.x. No problems so far.
Today I decided to upgrade my python install from 3.7.4 to 3.8.2.
Suddenly rtmclient.start() fails.
I saw a similar issue in another thread but the stacktraces are completely different.
I think the issue here is I use a proxy to connect to slack.
As of slackclient 2.x, proxies are http only, see my code in attachment.

Another important thing to note:
I managed to get all of the same libraries in the same versions as I had with python 3.4.7 except for the lazy-object-proxy lib that I had to upgrade because I could no longer download this version.
See requirements.txt in attachments section.

For now I am going back to my python 3.7.4 env. But I would love for this to be fixed so I can upgrade... Thanks for any help :)

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

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

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

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • 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: 2.5.0

python version: 3.8.2

OS version(s): Windows 10 Version 10.0.18363 Build 18363

Steps to reproduce:

  1. Start rtmclient with a proxy?
  2. Instant Crash

Expected result:

My bot starts up normally like it does with my python 3.7.4 environment.

Actual result:

Traceback (most recent call last):
  File "C:\Users\dsebton\AppData\Local\Programs\Python\Python38\lib\site-packages\aiohttp\connector.py", line 936, in _wrap_create_connection
    return await self._loop.create_connection(*args, **kwargs)  # type: ignore  # noqa
  File "C:\Users\dsebton\AppData\Local\Programs\Python\Python38\lib\asyncio\base_events.py", line 1050, in create_connection
    transport, protocol = await self._create_connection_transport(
  File "C:\Users\dsebton\AppData\Local\Programs\Python\Python38\lib\asyncio\base_events.py", line 1080, in _create_connection_transport
    await waiter
  File "C:\Users\dsebton\AppData\Local\Programs\Python\Python38\lib\asyncio\proactor_events.py", line 395, in _loop_writing
    self._write_fut = self._loop._proactor.send(self._sock, data)
  File "C:\Users\dsebton\AppData\Local\Programs\Python\Python38\lib\asyncio\windows_events.py", line 525, in send
    self._register_with_iocp(conn)
  File "C:\Users\dsebton\AppData\Local\Programs\Python\Python38\lib\asyncio\windows_events.py", line 714, in _register_with_iocp
    _overlapped.CreateIoCompletionPort(obj.fileno(), self._iocp, 0, 0)
OSError: [WinError 87] The parameter is incorrect

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File ".\launcher.py", line 20, in <module>
    launcher()
  File ".\launcher.py", line 18, in launcher
    slackbot_v2.bot_startup()
  File "C:\Users\dsebton\Desktop\scrape_butler\py-butler\slackbot_v2.py", line 120, in bot_startup
    rtmclient.start()
  File "C:\Users\dsebton\AppData\Local\Programs\Python\Python38\lib\site-packages\slack\rtm\client.py", line 198, in start
    return self._event_loop.run_until_complete(future)
  File "C:\Users\dsebton\AppData\Local\Programs\Python\Python38\lib\asyncio\base_events.py", line 616, in run_until_complete
    return future.result()
  File "C:\Users\dsebton\AppData\Local\Programs\Python\Python38\lib\site-packages\slack\rtm\client.py", line 329, in _connect_and_read
    url, data = await self._retreive_websocket_info()
  File "C:\Users\dsebton\AppData\Local\Programs\Python\Python38\lib\site-packages\slack\rtm\client.py", line 503, in _retreive_websocket_info
    resp = await self._web_client.rtm_connect()
  File "C:\Users\dsebton\AppData\Local\Programs\Python\Python38\lib\site-packages\slack\web\base_client.py", line 213, in _send
    res = await self._request(
  File "C:\Users\dsebton\AppData\Local\Programs\Python\Python38\lib\site-packages\slack\web\base_client.py", line 244, in _request
    async with session.request(http_verb, api_url, **req_args) as res:
  File "C:\Users\dsebton\AppData\Local\Programs\Python\Python38\lib\site-packages\aiohttp\client.py", line 1012, in __aenter__
    self._resp = await self._coro
  File "C:\Users\dsebton\AppData\Local\Programs\Python\Python38\lib\site-packages\aiohttp\client.py", line 480, in _request
    conn = await self._connector.connect(
  File "C:\Users\dsebton\AppData\Local\Programs\Python\Python38\lib\site-packages\aiohttp\connector.py", line 523, in connect
    proto = await self._create_connection(req, traces, timeout)
  File "C:\Users\dsebton\AppData\Local\Programs\Python\Python38\lib\site-packages\aiohttp\connector.py", line 855, in _create_connection
    _, proto = await self._create_proxy_connection(
  File "C:\Users\dsebton\AppData\Local\Programs\Python\Python38\lib\site-packages\aiohttp\connector.py", line 1093, in _create_proxy_connection
    transport, proto = await self._wrap_create_connection(
  File "C:\Users\dsebton\AppData\Local\Programs\Python\Python38\lib\site-packages\aiohttp\connector.py", line 943, in _wrap_create_connection
    raise client_error(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host www.slack.com:443 ssl:default [The parameter is incorrect]

Attachments:

Code :

def bot_startup():
    """Starts up the slack bot."""
    proxy = 'http://proxy.mycompany.lan:XXXX'
    slack_token = os.environ["SLACK_API_TOKEN"]
    rtmclient = slack.RTMClient(token=slack_token, proxy=proxy)
    rtmclient.start()

Requirements.txt :

aiohttp==3.6.2
astroid==2.3.2
async-timeout==3.0.1
attrs==19.3.0
certifi==2019.9.11
chardet==3.0.4
colorama==0.4.1
idna==2.8
isort==4.3.21
lazy-object-proxy>=1.4.2
mccabe==0.6.1
multidict==4.5.2
pylint==2.4.3
requests==2.22.0
six==1.12.0
slackclient==2.5.0
typed-ast==1.4.0
urllib3==1.25.6
websocket-client==0.54.0
wrapt==1.11.2
xmltodict==0.12.0
yarl==1.3.0

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions