slackapi / bolt-js

A framework to build Slack apps using JavaScript
https://tools.slack.dev/bolt-js/
MIT License
2.75k stars 393 forks source link

Custom HTTP routes and socket mode? #1266

Closed albarivas closed 2 years ago

albarivas commented 2 years ago

Description

I have a custom HTTP route defined:

const salesforceMessageCallback = {
    path: '/salesforce/message',
    method: ['POST'],
    handler: salesforceMessageHandler
};

This route can be reached correctly when my app is deployed to heroku, posting to https://my-app.heroku.com/salesforce/message. Now, I am trying to use socket mode, so that I can do local development. The rest of the app works fine in socket mode. But I want to be able to make a post request to that custom HTTP route (when using socket mode) and I'm not sure how do it. I've tried reaching https://localhost:3000/salesforce/message with postman but I am receiving this error:

Error: write EPROTO 140634789023016:error:100000f7:SSL routines:OPENSSL_internal:WRONG_VERSION_NUMBER:../../third_party/boringssl/src/ssl/tls_record.cc:242:

As with socket mode the app runs over websocket protocol, I am not sure if I can use HTTPS to callout to custom HTTP routes, or how should I do it. Any help is appreciated. Thanks.

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

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


Bug Report

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

Reproducible in:

package version:

node version:

OS version(s):

Steps to reproduce:

1. 2. 3.

Expected result:

What you expected to happen

Actual result:

What actually happened

Attachments:

Logs, screenshots, screencast, sample project, funny gif, etc.

misscoded commented 2 years ago

Hi @albarivas! Your hunch is correct about not using HTTPS when running locally. Using HTTP (http://localhost:3000/salesforce/message) should work just fine for local development, and you can utilize HTTPS for prod, as you've done and already gotten to work.

Let us know if that sorts the issue out!

albarivas commented 2 years ago

@misscoded I am getting this error when using http:

Failed to post messages to Slack: HTTP403 Forbidden - <html><head><title>ACCESS DENIED</title></head><body id=ERR_ACCESS_DENIED>
albarivas commented 2 years ago

Hi, this issue was auto resolved - probably an upgrade on Slack side as I notice some differences in the app configuration UI. I can confirm that this use case works as expected. Thank you for your help!