rtm_connect() is always returning False
following guide here will show the issue:
http://slackapi.github.io/python-slackclient/real_time_messaging.html#connecting-to-the-real-time-messaging-api
For my project I was using docker with python 2.75 + ubuntu 16.04
sc.rtm_connect() should return true
Always returns false.
I got feedback from slack about the issue and they were suggesting that I try out the newer rtm.connect method
https://api.slack.com/changelog/2017-04-start-using-rtm-connect-and-stop-using-rtm-start
I believe this is in reference to this line: https://github.com/slackapi/python-slackclient/blob/master/slackclient/_server.py#L70
I'm seeing the same error. I stepped through this with pdb and it seems to error out here: https://github.com/slackapi/python-slackclient/blob/master/slackclient/_server.py#L107 with this error message TypeError('cafile, capath and cadata cannot be all omitted',) which looks like some sort of certificate error.
Add sslopt={"cert_reqs": ssl.CERT_NONE} in https://github.com/slackapi/python-slackclient/blob/master/slackclient/_server.py#L103
Would it be possible to have the connect throw an exception rather than just returning False? It would greatly help me understand what has gone wrong.
on this line: https://github.com/slackapi/python-slackclient/blob/f8ebd4a20e513792748d3689eb375528a389f84f/slackclient/_server.py#L109
by using ipdb I managed to find the following error
File "/home/app/lib/python3.5/site-packages/websocket/_http.py", line 138, in _wrap_sni_socket
context.load_verify_locations(cafile=sslopt.get('ca_certs', None), capath=sslopt.get('ca_cert_path', None))
TypeError: cafile, capath and cadata cannot be all omitted
Is it possible to use raise from? I'm not sure how backwards compatible that would be but it is nice to be able to see the causes of the exceptions.
Update:
I went and installed the requirements.txt that was in the repo:
https://github.com/slackapi/python-slackclient/blob/master/requirements.txt
specifically this 'websocket-client==0.35.0'
reran and it's back up to working! Thanks to Guanliang Chen for pointing me in that direction!
possible the docker image I was using had an update removing one of those packages? unsure why it worked before.
Confirmed that websocket-client==0.35.0 in requirements is a fix. (We've actually gone with 0.40.0 which also seems to work)
My problem before: (pipdeptree output):
```
slackclient==1.0.5
I had a same problem and websocket-client==0.40.0 solved this.
im working on some packaging cleanup in #188. im adding version range specifiers to the dependencies, and currently i have websocket-client >=0.16, <1.0a0. but it seems like from this issue, i should change that to websocket-client >=0.35, <1.0a0.
i haven't tried reproducing, but do we agree that this would fix the issue?
@aoberoi - possibly... For me the only thing I did between working and not working was to docker build using ubuntu 16.04 image. I hadn't modified slackclient (was at 1.0.5) - I am guessing something new was pushed to the docker image that caused this?
@Zechtitus i'm guessing your Dockerfile does a fresh pip install -r requirements.txt in there somewhere, so your new build probably got a later version of websocket-client. is there any way you could access the non-working docker image and figure out what version of websocket-client was on it?
@aoberoi - found one app I hadn't upgraded yet. This is weird as if I'm reading this correct it was saying 0.43.0 of websocket-client was installed... but this app was still getting the False back with the rtm_connect() call
from pipdeptree
slackclient==1.0.4
Would it be possible to have the connect throw an exception rather than just returning False? It would greatly help me understand what has gone wrong.
@gbigwood I agree. Much of the error handling in this module could use some refactoring. Many errors are either not propagated up the chain properly or completely hidden from the developer.
We've been working out roadmaps for our SDK projects and improved error handling is a common theme among them.
okay, im going to try a few versions locally and see if i can help narrow down the offending version (if that's truly the only thing wrong)
alright folks, i think we've narrowed it down. it seems to be caused by https://github.com/websocket-client/websocket-client/commit/287db85a429a3c413411415663fde8c5a339de42.
@Roach and i submitted a patch (websocket-client/websocket-client#328) and hopefully that gets merged and released.
so in conclusion, the v0.43.0 release of websocket-client is broken. its no coincidence that this issue started getting reported here a day ago (when that version was released). lets be patient for the next release or revert to a previous one.
猬嗭笍 that was a mistake because of auto-closing from the commit.
im mostly certain that v0.44.0 on pip includes our patch. i'll go ahead and close this issue.
@aoberoi Hmm, I am still getting False from rtm_connect(). Using slackclient (1.0.6) and websocket-client (0.44.0).
I was experiencing this error, updating websocket-client to v0.44.0 via pip indeed fixed it for me.
@edwinksl are you able to either of the following?
server.py line 103 and try stepping over until you see an error, or;rtm_connect()python
import websocket
websocket.enableTrace(True)
if you can do (1), then please see if the exception matches the one we're talking about and let me know.
if you can do (2), can you post the trace output you see on the console (please redact any tokens or confidential information)?
@aoberoi My bad, there was a missing scope, which I have now fixed, so it wasn't a problem with rtm_connect(). After adding the missing scope, rtm_connect() works as expected.
I have the same issue using slackclient (1.0.6) and websocket-client (0.44.0).
after calling
client = slackclient.SlackClient(botToken)
The following returns True
client.api_call("users.list").get('ok')
While client.rtm_connect() is False
I also tried websocket.enableTrace(True) but no output gets printed on terminal
@mariob6 As noted above, you need to upgrade websocket-client to 0.44.0.
@edwinksl my bad I updated it while trying but still no luck (I changed my comment)
@mariob6 i'm not sure what to say about no output with enableTrace(), but have you tried debugging with pdb? is there any new information about the issue since you last commented?
thanks @aoberoi I was using bash on Ubuntu on Windows, I switched to a full Ubuntu system and it worked smoothly
i'm glad you got it working!
its a shame the bash on Windows support is a little more nuanced. if you have any more details about that problem, we could start documenting what we know about it in a new github issue.
Most helpful comment
alright folks, i think we've narrowed it down. it seems to be caused by https://github.com/websocket-client/websocket-client/commit/287db85a429a3c413411415663fde8c5a339de42.
@Roach and i submitted a patch (websocket-client/websocket-client#328) and hopefully that gets merged and released.
so in conclusion, the v0.43.0 release of websocket-client is broken. its no coincidence that this issue started getting reported here a day ago (when that version was released). lets be patient for the next release or revert to a previous one.