node-slack-sdk icon indicating copy to clipboard operation
node-slack-sdk copied to clipboard

A WebSocket error occurred: Client network socket disconnected before secure TLS connection was established

Open srigar opened this issue 2 years ago • 3 comments

(Filling out the following with as much detail as you can provide will help us solve your issue sooner.)

Packages:

Select all that apply:

  • [X] @slack/web-api
  • [ ] @slack/rtm-api
  • [ ] @slack/webhooks
  • [ ] @slack/oauth
  • [X] @slack/socket-mode
  • [ ] I don't know

Reproducible in:

The Slack SDK version

"slack/bolt": "^3.11.3",
"slack/logger": "^3.0.0",
"slack/oauth": "^2.5.3",
"slack/types": "^2.5.0",
"slack/socket-mode": "^1.3.1",
"slack/web-api": "^6.7.2",

Node.js runtime version

node 14.19.3

OS info

Docker node-alpine-14.19.3

Steps to reproduce:

(Share the commands to run, source code, and project settings) Im just trying to deploy the sample code in the server(GCP) via docker and it is failed to start. The same has been working in my local.

const { SocketModeClient } = require("@slack/socket-mode");

const socketModeClient = new SocketModeClient({
  appToken: process.env.APP_TOKEN,
});

socketModeClient.on("message", async ({ event, body, ack }) => {
  await ack();
});

(async () => {
  // Connect to Slack
  await socketModeClient.start();
})();

Dockerfile for reference,

FROM node:14.19.3-alpine
ENV NODE_ENV production
ENV NODE_TLS_REJECT_UNAUTHORIZED='0'
WORKDIR /usr/local/test
COPY . .
RUN ls -lrt
EXPOSE 8080
CMD ["node", "."]

Expected result:

[INFO]  socket-mode:SocketModeClient:0 Going to establish a new connection to Slack ...
[INFO]  socket-mode:SocketModeClient:0 Now connected to Slack

Actual result:

[ERROR]  socket-mode:SocketModeClient:0 A WebSocket error occurred: Client network socket disconnected before secure TLS connection was established
[INFO]  socket-mode:SocketModeClient:0 Reconnecting to Slack ...
[INFO]  socket-mode:SocketModeClient:0 Going to establish a new connection to Slack ..

srigar avatar Jun 26 '22 10:06 srigar

Hi @srigar thanks for witting in!

Before I go ahead and try to reproduce this on my end I just want to confirm that the APP_TOKEN environment variable is set in your docker container. The referenced dockerfile does not seem to set this variable, I would enjoy more context as to how this value is passed to the container?

WilliamBergamin avatar Jun 27 '22 23:06 WilliamBergamin

@WilliamBergamin Thanks for jumping in! If the tokens are not provided to the Docker containers, the error can be a bit different.

@srigar I've verified that your Dockerfile works for me in my local machine. Thus, this is obviously an issue specific to your GCP environment. Since we are not here as GCP experts, we are unable to help you out in details for GCP. By googling the error message "Client network socket disconnected before secure TLS connection was established", you will see so many Q&A pages. I hope that you will figure the cause out soon!

seratch avatar Jun 28 '22 00:06 seratch

👋 It looks like this issue has been open for 30 days with no activity. We'll mark this as stale for now, and wait 10 days for an update or for further comment before closing this issue out. If you think this issue needs to be prioritized, please comment to get the thread going again! Maintainers also review issues marked as stale on a regular basis and comment or adjust status if the issue needs to be reprioritized.

github-actions[bot] avatar Aug 01 '22 00:08 github-actions[bot]

As this issue has been inactive for more than one month, we will be closing it. Thank you to all the participants! If you would like to raise a related issue, please create a new issue which includes your specific details and references this issue number.

github-actions[bot] avatar Aug 15 '22 00:08 github-actions[bot]