Netflix / hubcommander

A Slack bot for GitHub organization management -- and other things too
Apache License 2.0
1.28k stars 156 forks source link

Issue setting up with Linux for Windows: "AttributeError: 'NoneType' object has no attribute 'recv'" #95

Closed dylmye closed 5 years ago

dylmye commented 5 years ago

Hi, I'm trying to set up hubcommander so I can do a PR. I've got Debian Wheezy on Linux Subsystem. I've done the following from scratch:

I get the following stack trace when running the rtmbot command:

(venv) dylmye-debian@DYLMYE-HOME-PC:~/hacktober/python-rtmbot-0.4.0$ rtmbot
[-->] Enabling Auth Plugins
[✔] Completed enabling auth plugins plugins.
[-->] Enabling Command Plugins
[ ] Enabling Command Plugin: repeat
        [+] Adding command: '!Repeat'
        [+] Adding command: '!RepeatThread'
[+] Successfully enabled command plugin "repeat"
[ ] Enabling Command Plugin: github
        [+] Adding command: '!ListOrgs'
        [+] Adding command: '!DeleteRepo'
        [+] Adding command: '!AddCollab'
        [+] Adding command: '!SetDefaultBranch'
        [+] Adding command: '!SetTopics'
        [+] Adding command: '!ListPRs'
        [+] Adding command: '!GetKey'
        [+] Adding command: '!CreateRepo'
        [+] Adding command: '!SetRepoPermissions'
        [+] Adding command: '!ListKeys'
        [+] Adding command: '!SetHomepage'
        [+] Adding command: '!AddKey'
        [+] Adding command: '!DeleteKey'
        [+] Adding command: '!SetDescription'
        [+] Adding command: '!SetBranchProtection'
        [+] Adding command: '!AddUserToTeam'
[+] Successfully enabled command plugin "github"
[✔] Completed enabling command plugins.
Traceback (most recent call last):
  File "/usr/local/bin/rtmbot", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.5/dist-packages/rtmbot/bin/run_rtmbot.py", line 31, in main
    bot.start()
  File "/usr/local/lib/python3.5/dist-packages/rtmbot/core.py", line 99, in start
    self._start()
  File "/usr/local/lib/python3.5/dist-packages/rtmbot/core.py", line 86, in _start
    for reply in self.slack_client.rtm_read():
  File "/usr/local/lib/python3.5/dist-packages/slackclient/client.py", line 235, in rtm_read
    json_data = self.server.websocket_safe_read()
  File "/usr/local/lib/python3.5/dist-packages/slackclient/server.py", line 278, in websocket_safe_read
    data += "{0}\n".format(self.websocket.recv())
AttributeError: 'NoneType' object has no attribute 'recv'

Anything I'm missing out? Any additional information I can provide to help? Thank you!!

mikegrima commented 5 years ago

I have sometimes seen this error before when debugging on Dockers, and it's a bit of a hair puller to debug.

I think it could be related to the system clock in the Docker not being set properly.

dylmye commented 5 years ago

I'm not using Docker but this sounds like a clue - perhaps something to do with Debian on Linux Subsystem and system clocks.

As this stems from this function from python-slackclient is it worth raising an issue there or pinging someone from their team? :)

mikegrima commented 5 years ago

Can you verify that the system time on your Linux container is correct when you see this?

I believe users have brought that up to their attention, but nothing was patched AFAIK.

dylmye commented 5 years ago

Not so familiar with checking this but running date provides the right date for my timezone

dylmye commented 5 years ago

Looking at this issue from a product using the same library, perhaps we're missing some logs? Any log levels I can change in case I am actually getting slack login errors? :/

mikegrima commented 5 years ago

Oh interesting. IIRC, there is a DEBUG flag in the rtm conf file, which may help.

dylmye commented 5 years ago

Found this in rtmbot.log:

2018-10-08 01:08:09,716 Initialized in: /usr/local/bin
2018-10-08 01:08:09,795 Starting new HTTPS connection (1): slack.com:443
2018-10-08 01:08:10,004 https://slack.com:443 "POST /api/rtm.start HTTP/1.1" 200 131
2018-10-08 01:08:10,007 Failed RTM connect
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/slackclient/client.py", line 140, in rtm_connect
    self.server.rtm_connect(use_rtm_start=with_team_state, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/slackclient/server.py", line 163, in rtm_connect
    raise SlackLoginError(reply=reply)
slackclient.server.SlackLoginError
2018-10-08 01:08:10,009 Loading plugins
2018-10-08 01:08:10,009 Importing hubcommander.hubcommander.HubCommander
2018-10-08 01:08:10,237 Plugin registered: <hubcommander.hubcommander.HubCommander object at 0x7f53672e9668>
2018-10-08 01:08:10,237 Registering jobs for HubCommander
2018-10-08 01:08:10,237 No jobs registered for HubCommander

I'm pretty sure that the token is correct but I'll have a deeper dig. Other than that, perhaps it would be useful to catch SlackLoginErrors if possible :) Possibly related to this issue

To anyone reading this in the future - make sure you add a bot user to your app. Now when you install this app into a workplace you'll get a bot user oauth token. :)