Forums

Slack API - rtm_connect error

When attempting to use the Slack API (Real Time Messaging) I get what seems to be a certification error. I have a paid (hacker account) and the code works fine from my local machine.

Any ideas why this is happening? Would love to get some feedback to point me in the right direction.

import os
from slackclient import SlackClient
verif_token = os.environ.get("MYTOKEN")
slack_client = SlackClient(verif_token)
slack_client.rtm_connect(with_team_state=False)


Traceback (most recent call last):
File "/home/lucasmalta/.local/lib/python2.7/site-packages/slackclient/client.py", line 52, in rtm_connect
self.server.rtm_connect(use_rtm_start=with_team_state, **kwargs)
File "/home/lucasmalta/.local/lib/python2.7/site-packages/slackclient/server.py", line 147, in rtm_connect
self.connect_slack_websocket(self.ws_url)
File "/home/lucasmalta/.local/lib/python2.7/site-packages/slackclient/server.py", line 186, in connect_slack_websocket
raise SlackConnectionError(message=str(e))
SlackConnectionError: _ssl.c:335: No root certificates specified for verification of other-side certificates.

The only thing i can think of is that perhaps you are still using an old console before your upgrade? Try killing all your old consoles, starting a new console and running that? (this is being run from a console right?)

Thanks. This is not the problem actually. I have re-opened all of the consoles after upgrading my account.

The slack_client = SlackClient(verif_token) piece is working. I can see a list of my users with api_call = slack_client.api_call("users.list")

However, rtm_connect does not work. Does it work for you? If so, have you changed anything in regards to CA-related information?

And I forgot to mention that I am using python 2.7.

If looks like this may be a known issue with the websocket library that slack uses: https://github.com/slackapi/python-slackclient/issues/334. One suggestion there seems to be to downgrade the websocket module to one before the change.

It worked! Thank you.

Downgrading the websocket-client library to 0.47.0 did the trick.

Excellent -- thanks for confirming!