python-slack-sdk: Getting 404 error from WS URL in RTMClient#start() with aiohttp 3.7.0 or lower versions

RTMClient.start() failing as of 2021-01-09. Connection attempted with both slack_sdk and (legacy) slackclient.

The Slack SDK version

slack-sdk 3.1.1

(Also occuring on slackclient 2.9.3)

Python runtime version

Python 3.6.7

OS info

Microsoft Windows [Version 10.0.18362.1256]

Steps to reproduce:

> import slack_sdk.rtm as rtm

> rtm_client = rtm.RTMClient(token=token) # also attempted with ssl_context provided
> rtm_client.start()

Testing via https://api.slack.com/methods/rtm.connect/test is successful with the same token as used when running code sample above.

Actual result:

  File "C:\Program Files\Python36\lib\asyncio\base_events.py", line 473, in run_until_complete
    return future.result()
  File "D:\Repos\analysis-tools\slack-bot\src\env\lib\site-packages\slack_sdk\rtm\__init__.py", line 360, in _connect_and_read
    proxy=self.proxy,
  File "D:\Repos\analysis-tools\slack-bot\src\env\lib\site-packages\aiohttp\client.py", line 1012, in __aenter__
    self._resp = await self._coro
  File "D:\Repos\analysis-tools\slack-bot\src\env\lib\site-packages\aiohttp\client.py", line 738, in _ws_connect
    headers=resp.headers)
aiohttp.client_exceptions.WSServerHandshakeError: 404, message='Invalid response status', url=URL('wss://cerberus-xxxx.lb.slack-msgs.com/websocket/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 21
  • Comments: 42 (9 by maintainers)

Commits related to this issue

Most upvoted comments

For those of you experiencing this issue, we’d like to know if you are (👍) or are not (👎) using the proxy option to connect via a proxy. Would you mind reacting to this comment?

Same problem. Python 3.6, OpenSSL 1.1.1.

Looks like there may be a lot of us. Perhaps we should switch to 👍 on the post if we have no new info to add?

I was facing the same issue. It started working after doing the following:

  1. Upgrading aiohttp - pip install -U aiohttp
  2. from slack import RTMClient -> from slack_sdk.rtm import RTMClient

this worked for me - thanks very much

To: all in this thread Thank you very much for sharing the workaround.

I was on 3.6.2, upgraded to 3.7.3 and everything started working again.

@brendan-mz Thanks a lot for this helpful information. I managed to reproduce the issue with aiohttp==3.6.2 too.

While our server-side teams are actively working on this and the issue will be resolved soon, as a workaround at this point, please upgrade your aiohttp version to the 3.7.1 or higher if you’re using an older version.

Update: using aiohttp==3.7.3 (at least 3.7.1+) is recommended. It seems 3.7.0 does not work due to another issue.

Confirming the aiohttp upgrade works. I was on 3.6.2, upgraded to 3.7.3 and everything started working again.

Confirming the aiohttp upgrade works. I was on 3.6.2, upgraded to 3.7.3 and everything started working again.

works for me. :flower:

Upgrading aiohttp worked for me too. Thanks a lot!

For anyone else running into this that isn’t using aiohttp, it appears this was the change to aiohttp that made the difference.

If your client implementation sends any capitalization other than Upgrade: websocket (e.g. Upgrade: WebSocket) you’ll get the 404.

In my case, I patched autobahn here: https://github.com/crossbario/autobahn-python/blob/master/autobahn/websocket/protocol.py#L3576

Upgraded to aiohttp==3.7.3 and it works But there is big delay between question from user and bot receiving the question now

@hkonala I am sorry to say that, in your case, there is no workaround until the issue is fixed on the server-side. I cannot tell the exact timing of the deployment, but they will resolve this early tomorrow, Pacific Time. Again, we are sorry for the disruption.

For me also. Thanks.

According to the server-side teams, no apps should be experiencing this issue now. We apologize for the inconvenience and appreciate your patience.

Saving me. SAVING ME!!! aiohttp-3.7.3

Upgrading to aiohttp-3.7.3 and slackclient-2.9.3 fixed the issue. Thanks a ton.

[slackbot@xxxxslackbot]$ pip3 install -U aiohttp --proxy http://x.x.x:8888 --user slackbot … Successfully installed aiohttp-3.7.3 attrs-20.3.0 certifi-2020.12.5 idna-3.1 multidict-5.1.0 requests-2.25.1 urllib3-1.26.2 yarl-1.6.3

[slackbot@xxxx slackbot]$ [slackbot@xxxx slackbot]$ pip3 install -U slackclient --proxy http://x.x.x:8888 --user slackbot … Successfully installed idna-2.10 slackclient-2.9.3 [slackbot@xxxx slackbot]$

Working for me too after aiohttp upgrade. Thanks for the help!

we just deployed a new release upgrading slackclient from v2.7.3 to v2.9.3 and it seems to be working now.

@seratch I’m not familiar with node, i try to do the following steps:

  • npm install @slack/rtm-api
  • create a test.js with content:
    const { RTMClient } = require('@slack/rtm-api');
    
    // Read a token from the environment variables
    const token = 'xoxb-xxxxxxxxxxxxxxx';
    
    // Initialize
    const rtm = new RTMClient(token);
    
    (async () => {
      // Connect to Slack
      const { self, team } = await rtm.start();
    })();
    
  • run node test.js

and there‘s no output or error with correct token. If I set a wrong token, it raise an UnhandledPromiseRejectionWarning: Error: An API error occurred: invalid_auth, so I guess Node SDK works fine.

I got the same error since last night(01/11), without modifying any code. Maybe it’s a slack server error?