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.

Custom receiver not respected when when using Socket Mode

See original GitHub issue

Description

Hey friends,

I’m working on a Bolt app which uses the Adding Custom HTTP routes feature:

const { App, ExpressReceiver } = require("@slack/bolt")

const receiver = new ExpressReceiver({/* ... */})
receiver.router.get("/", (req, res) => res.send('Hello world'))

const app = new App({receiver, /* ... */})

I’m personally using this feature to serve a OAuth login flow over HTTP that works together with the Slack app to log folks into another service.

Recently, I became aware of Socket Mode, which is helpful in working around having a public webhook in my development environment.

Enabling socketMode in the App quietly discards my custom receiver.

My request is two part-er:

  1. 🐛 BUG: It would be great if the App raised an error if you set socketMode and pass a customer receiver if the behaviour is to discard the receiver.
  2. ⚡ ENHANCEMENT: I’m not entirely sure how this would work, but I’d like to a) use socketMode and b) add custom HTTP routes

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

Steps to reproduce:

  1. Create an App, add a custom receiver with HTTP routes
  2. Enable socketMode on your app
  3. Navigate to your HTTP routes

Expected result:

The custom HTTP routes are accessible.

Actual result:

The custom HTTP routes are NOT accessible.


ps. Bolt was very straight forward to get started with and socketMode seems quite innovative and awesome! Thanks for your hard work on this. ❤️ ❤️ ❤️

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:22
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

7reactions
majidmadecommented, Jul 16, 2021

Hi friends,

I have a use case that’s likely very similar to others’ – I want to use socket mode, but need to expose some custom routes (/version, /health, /metrics) for various operational reasons.

This worked for me; sharing here in case it helps someone else. (Honestly, I’m a little surprised this worked, so YMMV.)

Create receiver:

const receiver = new ExpressReceiver({
  signingSecret: process.env.SLACK_SIGNING_SECRET
});

Create app:

const app = new App({
  token: process.env.SLACK_BOT_TOKEN,
  signingSecret: process.env.SLACK_SIGNING_SECRET,
  socketMode: true,
  appToken: process.env.SLACK_APP_TOKEN
});

Note that I did not pass the receiver into the app.

Now just start them independently:

await app.start(PORT);
await receiver.start(PORT);

¯\(ツ)

This feels hacky, so I’m still +1’ing the original issue. In the interim, though, hope this is useful to someone!

3reactions
misscodedcommented, Sep 21, 2021

Support for custom HTTP routes has been introduced and will be available with the release of 3.7.0. 🙂

With #1068 and #866 now both resolved, we’re going to close this issue. Thank you to all those that participated, from upvoting to providing details around use cases! 🙏🏼

Read more comments on GitHub >

github_iconTop Results From Across the Web

Intro to Socket Mode - Slack API
Socket Mode allows your app to communicate with Slack via a WebSocket URL. WebSockets use a bidirectional stateful protocol with low latency to...
Read more >
How to use Bolt events with the newer Slack API manifests?
I've now turned off socket mode and got ngrok working as described here. Slack was able to validate the url anyway. But what's...
Read more >
Socket Programming in Python (Guide)
In this in-depth tutorial, you'll learn how to build a socket server and client with Python. By the end of this tutorial, you'll...
Read more >
Java Client API Guide - RabbitMQ
Application developers can assign a custom name to a connection. ... If the entity does not exist, the operation fails with a channel...
Read more >
4.5. TCP Socket Programming: HTTP
Processes running at the application layer of the protocol stack are not ... In this section, we will demonstrate how to use TCP...
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