{"action":"created","issue":{"url":"https://api.github.com/repos/slackapi/python-slackclient/issues/127","repository_url":"https://api.github.com/repos/slackapi/python-slackclient","labels_url":"https://api.github.com/repos/slackapi/python-slackclient/issues/127/labels{/name}","comments_url":"https://api.github.com/repos/slackapi/python-slackclient/issues/127/comments","events_url":"https://api.github.com/repos/slackapi/python-slackclient/issues/127/events","html_url":"https://github.com/slackapi/python-slackclient/issues/127","id":179915627,"number":127,"title":"Connection is already closed","user":{"login":"JohnB520","id":12599750,"avatar_url":"https://avatars.githubusercontent.com/u/12599750?v=3","gravatar_id":"","url":"https://api.github.com/users/JohnB520","html_url":"https://github.com/JohnB520","followers_url":"https://api.github.com/users/JohnB520/followers","following_url":"https://api.github.com/users/JohnB520/following{/other_user}","gists_url":"https://api.github.com/users/JohnB520/gists{/gist_id}","starred_url":"https://api.github.com/users/JohnB520/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JohnB520/subscriptions","organizations_url":"https://api.github.com/users/JohnB520/orgs","repos_url":"https://api.github.com/users/JohnB520/repos","events_url":"https://api.github.com/users/JohnB520/events{/privacy}","received_events_url":"https://api.github.com/users/JohnB520/received_events","type":"User","site_admin":false},"labels":[{"id":146535885,"url":"https://api.github.com/repos/slackapi/python-slackclient/labels/bug","name":"bug","color":"B92529","default":true},{"id":401184746,"url":"https://api.github.com/repos/slackapi/python-slackclient/labels/in%20progress","name":"in progress","color":"3aaf85","default":false},{"id":474745908,"url":"https://api.github.com/repos/slackapi/python-slackclient/labels/Priority%20-Medium","name":"Priority -Medium","color":"fef2c0","default":false}],"state":"closed","locked":false,"assignee":{"login":"Roach","id":32463,"avatar_url":"https://avatars.githubusercontent.com/u/32463?v=3","gravatar_id":"","url":"https://api.github.com/users/Roach","html_url":"https://github.com/Roach","followers_url":"https://api.github.com/users/Roach/followers","following_url":"https://api.github.com/users/Roach/following{/other_user}","gists_url":"https://api.github.com/users/Roach/gists{/gist_id}","starred_url":"https://api.github.com/users/Roach/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Roach/subscriptions","organizations_url":"https://api.github.com/users/Roach/orgs","repos_url":"https://api.github.com/users/Roach/repos","events_url":"https://api.github.com/users/Roach/events{/privacy}","received_events_url":"https://api.github.com/users/Roach/received_events","type":"User","site_admin":false},"assignees":[{"login":"Roach","id":32463,"avatar_url":"https://avatars.githubusercontent.com/u/32463?v=3","gravatar_id":"","url":"https://api.github.com/users/Roach","html_url":"https://github.com/Roach","followers_url":"https://api.github.com/users/Roach/followers","following_url":"https://api.github.com/users/Roach/following{/other_user}","gists_url":"https://api.github.com/users/Roach/gists{/gist_id}","starred_url":"https://api.github.com/users/Roach/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Roach/subscriptions","organizations_url":"https://api.github.com/users/Roach/orgs","repos_url":"https://api.github.com/users/Roach/repos","events_url":"https://api.github.com/users/Roach/events{/privacy}","received_events_url":"https://api.github.com/users/Roach/received_events","type":"User","site_admin":false}],"milestone":null,"comments":3,"created_at":"2016-09-28T23:19:55Z","updated_at":"2016-12-13T21:49:36Z","closed_at":"2016-12-09T18:43:50Z","body":"- [X] I've read and understood the [Contributing guidelines](https://github.com/slackhq/python-slackclient/blob/master/.github/CONTRIBUTING.md) and have done my best effort to follow them.\n- [X] I've read and agree to the [Code of Conduct](https://github.com/slackhq/python-slackclient/blob/master/CODE_OF_CONDUCT.md).\n- [X] I've searched for any related issues and avoided creating a duplicate issue.\n#### Description\n\nSlack teams with a significant number of users may never connect to Slack \nMy slack team has 9,500+ users and upon bot application startup will experience a \"connection is already closed\"\nIn commit 875839b - slackclient/_server.py.rtm_connect(self, reconnect=False):\n    If line 74 `self.connect_slack_websocket(self.ws_url)` is moved before `if not reconnect:` on line 72 it will allow the websocket to establish connection so then parse_slack_login_data can run for a lengthy duration without causing the issue.\n#### Reproducible in:\n- [?] This is reproducible in the sample project. -- Possibly if your team's user count is sufficiently large. \"large\" would mean that `parse_slack_login_data(self, login_data)` takes over 30 seconds; which is the validity period for the websocket url.  Alternatively you can import time and sleep 45(or so) seconds in the parse_slack_login_data function to simulate the delay I experience.\n  I resorted to console outputs to capture our real-world times while troubleshooting:\n\n```\nStart-parse in rtm_connect: 16:19:37\n    Start-parse channel-channels:   16:19:37\n    End-parse channel-channels: 16:19:39\n    Elapsed-parse channel-channels: 2.35307884216\n    Start-parse channel-groups: 16:19:39\n    End-parse channel-groups:   16:19:39\n    Elapsed-parse channel-groups:   0.00262713432312\n    Start-parse channel-ims:     16:19:39\n    End-parse channel-ims:  16:19:39\n    Elapsed-parse channel-ims:  0.00488305091858\n    Start-parse users:  16:19:39\n    End-parse users:    16:20:25\n    Elapsed-parse users:    45.6203141212\nEnd-parse in rtm_connect:   16:20:25\nElapsed-parse rtm_connect:  47.9812588692\n```\n\npython-slackclient version: slackclient-1.0.2(?)\nPython Version: 2.7.10\nOS Version: CentOS Linux release 7.1.1503 (Core)\n#### Steps to reproduce:\n1. \n2. \n3. \n### Expected result:\n\n> valid connection to Slack over RTM\n### Actual result:\n\n> ```Traceback (most recent call last):\n>   File ./rtmbot.py, line 26, in <module>\n>     bot.start()\n>   File /python-rtmbot/python-rtmbot/rtmbot/core.py, line 78, in start\n>     self._start()\n>   File /python-rtmbot/python-rtmbot/rtmbot/core.py, line 65, in _start\n>     for reply in self.slack_client.rtm_read():\n>   File /python-rtmbot/lib/python2.7/site-packages/slackclient/_client.py, line 120, in rtm_read\n>     json_data = self.server.websocket_safe_read()\n>   File /python-rtmbot/lib/python2.7/site-packages/slackclient/_server.py, line 184, in websocket_safe_read\n>     data += {0}n.format(self.websocket.recv())\n>   File /python-rtmbot/lib/python2.7/site-packages/websocket/_core.py, line 298, in recv\n>     opcode, data = self.recv_data()\n>   File /python-rtmbot/lib/python2.7/site-packages/websocket/_core.py, line 315, in recv_data\n>     opcode, frame = self.recv_data_frame(control_frame)\n>   File /python-rtmbot/lib/python2.7/site-packages/websocket/_core.py, line 328, in recv_data_frame\n>     frame = self.recv_frame()\n>   File /python-rtmbot/lib/python2.7/site-packages/websocket/_core.py, line 360, in recv_frame\n>     return self.frame_buffer.recv_frame()\n>   File /python-rtmbot/lib/python2.7/site-packages/websocket/_abnf.py, line 312, in recv_frame\n>     self.recv_header()\n>   File /python-rtmbot/lib/python2.7/site-packages/websocket/_abnf.py, line 261, in recv_header\n>     header = self.recv_strict(2)\n>   File /python-rtmbot/lib/python2.7/site-packages/websocket/_abnf.py, line 346, in recv_strict\n>     bytes = self.recv(min(16384, shortage))\n>   File /python-rtmbot/lib/python2.7/site-packages/websocket/_core.py, line 429, in _recv\n>     return recv(self.sock, bufsize)\n>   File /python-rtmbot/lib/python2.7/site-packages/websocket/_socket.py, line 89, in recv\n>     raise WebSocketConnectionClosedException(Connection is already closed.)\n> websocket._exceptions.WebSocketConnectionClosedException: Connection is already closed.\n> \n> ```\n> ```\n### Attachments:\n\n> e.g. Logs, screenshots, screencast, sample project, funny gif, etc.\n"},"comment":{"url":"https://api.github.com/repos/slackapi/python-slackclient/issues/comments/266872808","html_url":"https://github.com/slackapi/python-slackclient/issues/127#issuecomment-266872808","issue_url":"https://api.github.com/repos/slackapi/python-slackclient/issues/127","id":266872808,"user":{"login":"Roach","id":32463,"avatar_url":"https://avatars.githubusercontent.com/u/32463?v=3","gravatar_id":"","url":"https://api.github.com/users/Roach","html_url":"https://github.com/Roach","followers_url":"https://api.github.com/users/Roach/followers","following_url":"https://api.github.com/users/Roach/following{/other_user}","gists_url":"https://api.github.com/users/Roach/gists{/gist_id}","starred_url":"https://api.github.com/users/Roach/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Roach/subscriptions","organizations_url":"https://api.github.com/users/Roach/orgs","repos_url":"https://api.github.com/users/Roach/repos","events_url":"https://api.github.com/users/Roach/events{/privacy}","received_events_url":"https://api.github.com/users/Roach/received_events","type":"User","site_admin":false},"created_at":"2016-12-13T21:49:36Z","updated_at":"2016-12-13T21:49:36Z","body":"This has been deployed and is available in v1.0.3 🎉 "}}
{"actor":{"display_login":"Roach"}}