Skip to content

RTM client running in docker was disconnected immediately after first connection #386

Description

@murphytalk

Description

Running a very simple RTM client from docker, while rtm_connect() return True indicating a successful connection, the subsequent call to rtm_read() failed immediately.

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • testing related
  • discussion

Requirements (place an x in each of the [ ])

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

Bug Report

This is the simple script , it runs without any problem if it is not in docker container

if slack_client.rtm_connect():
    print("Connected to Slack")
    while True:
        slack_client.rtm_read()
        time.sleep(READ_WEBSOCKET_DELAY)

Reproducible in:

If run the script (see above) from a docker container, gets the following error

slack-bot       | DEBUG: Starting new HTTPS connection (1): slack.com:443
slack-bot       | DEBUG: https://slack.com:443 "POST /api/rtm.start HTTP/1.1" 200 5759
slack-bot       | DEBUG: RTM connected
slack-bot       | DEBUG: RTM disconnected
slack-bot       | Connected to Slack
slack-bot       | Traceback (most recent call last):
slack-bot       |   File "/usr/local/lib/python3.7/site-packages/slackclient/server.py", line 278, in websocket_safe_read
slack-bot       |     data += "{0}\n".format(self.websocket.recv())
slack-bot       |   File "/usr/local/lib/python3.7/site-packages/websocket/_core.py", line 313, in recv
slack-bot       |     opcode, data = self.recv_data()
slack-bot       |   File "/usr/local/lib/python3.7/site-packages/websocket/_core.py", line 330, in recv_data
slack-bot       |     opcode, frame = self.recv_data_frame(control_frame)
slack-bot       |   File "/usr/local/lib/python3.7/site-packages/websocket/_core.py", line 343, in recv_data_frame
slack-bot       |     frame = self.recv_frame()
slack-bot       |   File "/usr/local/lib/python3.7/site-packages/websocket/_core.py", line 377, in recv_frame
slack-bot       |     return self.frame_buffer.recv_frame()
slack-bot       |   File "/usr/local/lib/python3.7/site-packages/websocket/_abnf.py", line 361, in recv_frame
slack-bot       |     self.recv_header()
slack-bot       |   File "/usr/local/lib/python3.7/site-packages/websocket/_abnf.py", line 309, in recv_header
slack-bot       |     header = self.recv_strict(2)
slack-bot       |   File "/usr/local/lib/python3.7/site-packages/websocket/_abnf.py", line 396, in recv_strict
slack-bot       |     bytes_ = self.recv(min(16384, shortage))
slack-bot       |   File "/usr/local/lib/python3.7/site-packages/websocket/_core.py", line 452, in _recv
slack-bot       |     return recv(self.sock, bufsize)
slack-bot       |   File "/usr/local/lib/python3.7/site-packages/websocket/_socket.py", line 112, in recv
slack-bot       |     "Connection is already closed.")
slack-bot       | websocket._exceptions.WebSocketConnectionClosedException: Connection is already closed.
slack-bot       |
slack-bot       | During handling of the above exception, another exception occurred:
slack-bot       |
slack-bot       | Traceback (most recent call last):
slack-bot       |   File "/bot/bot.py", line 76, in <module>
slack-bot       |     run()
slack-bot       |   File "/bot/bot.py", line 71, in run
slack-bot       |     parseSlackRTM(slack_client.rtm_read())
slack-bot       |   File "/usr/local/lib/python3.7/site-packages/slackclient/client.py", line 235, in rtm_read
slack-bot       |     json_data = self.server.websocket_safe_read()
slack-bot       |   File "/usr/local/lib/python3.7/site-packages/slackclient/server.py", line 296, in websocket_safe_read
slack-bot       |     "Unable to send due to closed RTM websocket"
slack-bot       | slackclient.server.SlackConnectionError: Unable to send due to closed RTM websocket

slackclient version: latest

python version: 3.7

OS version(s): Linux

Steps to reproduce:

The docker image is built from the Dockerfile below:

FROM python:3.7.2-alpine3.8
RUN apk update && apk upgrade && \
    apk add --no-cache && apk add build-base && apk add libffi-dev && \
    apk add libxml2-dev && apk add libxslt-dev && apk add openssl-dev
RUN mkdir /app
COPY requirements.txt /app/
WORKDIR /app

The only package in requirements.txt is slackclient,

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions