Retry rtm.start if it fails
If you're connecting to multiple teams, especially if one of them is
large, the call to rtm.start may time out. By retrying it, there's a
greater chance that it works (especially since when it tries again, the
requests to rtm.start for the other teams have probably finished).
@@ -442,6 +442,13 @@ class EventRouter(object):
elif return_code != -1:
self.reply_buffer.pop(request_metadata.response_id, None)
self.delete_context(data)
+ if request_metadata.request == 'rtm.start':
+ w.prnt('', ('Failed connecting to slack team with token starting with {}, ' +
+ 'retrying. If this persists, try increasing slack_timeout.')
+ .format(request_metadata.token[:15]))
+ dbg('rtm.start failed with return_code {}. stack:\n{}'
+ .format(return_code, ''.join(traceback.format_stack())), level=5)
+ self.receive(request_metadata)
else:
if request_metadata.response_id not in self.reply_buffer:
self.reply_buffer[request_metadata.response_id] = StringIO()
