question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

slack_socket_mode_no_reply_received_error bot stopped responding with socket mode

See original GitHub issue

Description

Hello we had an issue with an internal slack bot that we have written.

It stopped responding to us and when we checked the logs they were full of:

{"code":"slack_socket_mode_no_reply_received_error"}
[ERROR]  socket-mode:SocketModeClient:0 cannot send message when client is not connected
(node:1) UnhandledPromiseRejectionWarning: Error: Cannot send message when client is not connected
    at Object.sendWhileDisconnectedError (/opt/app/node_modules/@slack/socket-mode/dist/errors.js:56:26)
    at /opt/app/node_modules/@slack/socket-mode/dist/SocketModeClient.js:333:33
    at new Promise (<anonymous>)
    at SocketModeClient.send (/opt/app/node_modules/@slack/socket-mode/dist/SocketModeClient.js:329:16)
    at ack (/opt/app/node_modules/@slack/socket-mode/dist/SocketModeClient.js:466:24)
    at App.processEvent (/opt/app/node_modules/@slack/bolt/dist/App.js:424:19)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async SocketModeClient.<anonymous> (/opt/app/node_modules/@slack/bolt/dist/receivers/SocketModeReceiver.js:90:13)

Not sure if it’s a mistake in our implementation or something lower level, any guidance welcomed,

The code can be found here: https://github.com/hmcts/slack-help-bot/blob/main/app.js

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

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • example code 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

Filling out the following details about bugs will help us solve your issue sooner.

Reproducible in:

package version: 3.0.0

node version: v14.8.0

OS version(s): 3.11.6 NAME=“Alpine Linux”

Steps to reproduce:

  1. I assume it’s to do with network connections not being handled properly but we only saw this once so far

Expected result:

bot reconnects automatically

Actual result:

bot was stuck in a disconnected state and didn’t respond to new events / messages until it was restarted

Attachments:

https://github.com/hmcts/slack-help-bot/blob/main/app.js

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
timjacommented, Dec 21, 2021

@Ohiekkar I implemented this work around to have my process monitor (Kubernetes in this case) restart it if this happened: https://github.com/hmcts/slack-help-bot/pull/46

No reports of issues since implementing that

1reaction
timjacommented, Sep 2, 2021

FWIW, the underlying “ws” package has been fixing bugs in v7 minor/patch versions. If your app uses a bit old version of it, upgrading ws to the latest may be worth trying. See also: slackapi/node-slack-sdk#1322

Seems we are on:

slack-help-bot@1.0.0 /Users/timja/projects/hmcts/slack-help-bot ├─┬ @slack/bolt@3.6.0 │ └─┬ @slack/socket-mode@1.1.0 │ └── ws@7.4.2 └─┬ jest@26.6.3 └─┬ @jest/core@26.6.3 └─┬ jest-config@26.6.3 └─┬ jest-environment-jsdom@26.6.2 └─┬ jsdom@16.4.0 └── ws@7.4.2 deduped

A little bit lower than the minimum version here: https://github.com/slackapi/node-slack-sdk/pull/1322/files, but either needs a resolution entry or a bump here I think? Is there any reason you aren’t using the 8.x version?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Intro to Socket Mode - Slack API
Socket Mode helps developers working behind a corporate firewall, or who have other security concerns that don't allow exposing a static HTTP endpoint....
Read more >
Socket Mode - Slack Platform Developer Tools
This package is designed to support Socket Mode, which allows your app to receive events from Slack over a WebSocket connection.
Read more >
External menu in socket mode? - Slack Community Forum
So I have created a slack-bot using the bolt-python framework and I have enabled socket mode for better security as it won't expose...
Read more >
Bolt-js in socket mode on heroku fails with Error R10
const {App} = require('@slack/bolt'); const app = new App({ token:process.env.bot_token, port: process.env.
Read more >
How to Build a Slackbot in Socket Mode with Python - Twilio
This makes building a Slackbot a bit more complicated. If your workspace is unprotected, then you might not need to create a bot...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found