Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bolt App also listens to requests on port 3000 even when it's not supposed to #1200

Closed
4 of 10 tasks
gl-pgege opened this issue Nov 8, 2021 · 3 comments · Fixed by #1202
Closed
4 of 10 tasks

Bolt App also listens to requests on port 3000 even when it's not supposed to #1200

gl-pgege opened this issue Nov 8, 2021 · 3 comments · Fixed by #1202
Assignees
Labels
question M-T: User needs support to use the project
Milestone

Comments

@gl-pgege
Copy link

gl-pgege commented Nov 8, 2021

Description

I'm working on creating a slack app that listens to messages in channels that the app is added into. Everything seems to work except the fact that when I'm running the Slack Bolt app (on port 3339), the app also seems to be receiving requests on port 3000. The problem is, I have a React application running on my local machine on port 3000 but when I go to localhost:3000 in my browser, it's the slack app responding instead of my react application. Want to also note that I upgraded to version 3.8.1 but still face this issue.

Would be great to find out if I'm doing anything wrong or if this is a bug.

Here's my code:

try {
    const app = new App({
        socketMode: true,
        appToken: SLACK_APP_TOKEN,
        signingSecret: SLACK_SIGNING_SECRET,
        clientId: SLACK_CLIENT_ID,
        clientSecret: SLACK_CLIENT_SECRET,
        stateSecret: 'my-secret',
        scopes: [
            'chat:write',
            'chat:write.customize',
            'channels:history',
            'groups:history',
            'im:history',
            'mpim:history'
        ],
        installationStore: {
            storeInstallation: async installation => {
                if (installation.team !== undefined) {
                    await slackService.addNewSlackAppData(installation as unknown as ISlackAppData)
                }
            },
            fetchInstallation: async installQuery => {
                if (installQuery.teamId !== undefined) {
                    const slackData = await slackService.getSlackAppDataByTeamId(installQuery.teamId);
                    if (slackData) {
                        return slackData as unknown as Installation;
                    }
                }

                throw new Error('Failed fetching installation');
            },
            deleteInstallation: async installQuery => {
                // REMOVE SLACKAPPDATA
            },
        },
        redirectUri: 'https://27c0-142-112-251-229.ngrok.io/slack/redirect', // here
        installerOptions: {
            redirectUriPath: '/slack/redirect', // and here!
        },
    })

    app.message(/.*/, this.handleMessage);

    // Start your app
    await app.start(3339);

    logger.info('⚡️ Bolt app is running!');
} catch (error) {
    logger.error(`BOT - ${error.message}`);
}

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.8.1

node version: 14.18.1

OS version(s): MacOS Big Sur 11.2.3

Steps to reproduce:

  1. Start bolt app on any port except 3000
  2. Send request on port 3000 while app is running

Expected result:

Expect the bolt app to not be listening on port 3000 because another port was assigned in app.start()

Actual result:

Bolt app responds to requests sent on port 3000.

E.g. Going to localhost:3000 responds with An unhandled HTTP request (GET) made to / was ignored

Attachments:

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

@filmaj
Copy link
Contributor

filmaj commented Nov 8, 2021

Hello @gl-pgege,

I think the issue is that you don't specify the port property as part of the parameters you construct your App with. Try adding something like this to your App construction:

const app = new App({
        socketMode: true,
        port: 3329,
        ...

Looking at the code for how the start method works, I do not believe passing the port number into the start() method does anything.

Let us know how that works out!

@filmaj filmaj self-assigned this Nov 8, 2021
@filmaj filmaj added the question M-T: User needs support to use the project label Nov 8, 2021
@ojaha065
Copy link

ojaha065 commented Nov 8, 2021

@filmaj

I do not believe passing the port number into the start() method does anything.

Passing a port number into start() is suggested in the getting started section of the documentation 🤔

@filmaj
Copy link
Contributor

filmaj commented Nov 8, 2021

Yes, good point @ojaha065 - this is a mistake in the documentation for the case where one uses the SocketModeReceiver. The HTTPReceiver, for example, does accept a port argument to the start method.

I will send a PR to fix the docs!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question M-T: User needs support to use the project
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants