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

Bottender ngrok "ghost session" prevents tunnel from opening #997

Open
AwesomeIndustry opened this issue Jul 1, 2023 · 1 comment
Open

Comments

@AwesomeIndustry
Copy link

Describe the bug
Hello,
I'm trying to get the Facebook Messenger channel set up by following the tutorial, but I'm having some trouble getting ngrok to work. I modified dev.js to print out the error object for more details:

catch (err) {
            if (!(err instanceof Error) && err.msg) {
                console.log(err); //<--- New line I added for more debugging
                throw new Error(`ngrok - ${err.msg}`);
            }
            throw err;
        }

And this is the error I got:


> [email protected] dev
> bottender dev

App has started
server is running on 5000 port...
{
  error_code: 103,
  status_code: 502,
  msg: 'failed to start tunnel',
  details: { err: 'remote gone away' }
}
✖ An unexpected error occurred in provider dev: ngrok - failed to start tunnel
Error: ngrok - failed to start tunnel
    at .../node_modules/bottender/dist/cli/providers/sh/dev.js:67:23
    at Generator.throw (<anonymous>)
    at rejected (.../node_modules/bottender/dist/cli/providers/sh/dev.js:6:65)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
^CApp has quit

(I'm on an M1 Mac running Monterey 12.6)

To Reproduce
Steps to reproduce the behavior:

  1. Build a simple Facebook Messenger Channel following the official guide
  2. Run npm run dev
  3. Get ngrok error

Expected behavior
I expect npm run dev to successfully start ngrok.

Additional context
It seems to me that the error code is either 103 (Account has been suspended) or 502 (limited to a certain number of max addresses), not sure which one it is.

I have ngrok installed via homebrew and when I run it with my access token it says I already have an ngrok session coming from my laptop's IP address. However, running top | grep ngrok or ps aux | grep ngrok reveals that there are no ngrok processes running. I even tried resetting my ngrok auth token and reauthenticating to prevent any old clients from connecting, but it still thinks I have this extra session.

I even edited my ngrok.yml file to delete my authtoken, and the (homebrew) ngrok client connects just fine without an account. However, bottender still gives me the above error. Where is bottender is getting this mystery authtoken and where this "ghost" process coming from? I couldn't find a ngrok.yml file inside my project (only the system-wide ngrok.yml exists). I'm starting to wonder if there's a hardcoded API key in the library somewhere, but I know that's absurd.

Does anyone know where this "ghost session" is coming from?

@AwesomeIndustry
Copy link
Author

Update: After some more poking around (and even hardwiring my ngrok token into the ngrok_1.default.connect() call), I'm starting to wonder if ngrok is being started by bottender but bottender can't connect to it to close it, so it stays running. I get some "connection refused" error sometimes before getting the 103/502 error:

> [email protected] dev
> bottender dev

App has started
server is running on 5000 port...
✖ An unexpected error occurred in provider dev: connect ECONNREFUSED 127.0.0.1:4040
Error: connect ECONNREFUSED 127.0.0.1:4040
    at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1247:16)
^[[A^CApp has quit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant