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

"ngrok is not yet ready to start tunnels" in Docker #148

Closed
miguelduarte42 opened this issue Jul 17, 2019 · 12 comments
Closed

"ngrok is not yet ready to start tunnels" in Docker #148

miguelduarte42 opened this issue Jul 17, 2019 · 12 comments

Comments

@miguelduarte42
Copy link
Contributor

miguelduarte42 commented Jul 17, 2019

Hi,

I'm getting this error every time I try to connect:

{ error_code: 104, status_code: 503, msg: 'ngrok is not yet ready to start tunnels', details: { err: 'a successful ngrok tunnel session has not yet been established' } }

Running ngrok on the command line works great, it just doesn't work when I call it using some node code:

const ngrok = require('ngrok');
ngrok.connect({addr: 5000,authtoken: MYTOKEN})
.then(url => console.log(url))
.catch(err => console.log(err));

This stopped working all of a sudden. Been working correctly for months.

@miguelduarte42 miguelduarte42 changed the title "ngrok is not yet ready to start tunnels" in Travis "ngrok is not yet ready to start tunnels" in Docker Jul 17, 2019
@paton
Copy link

paton commented Jul 17, 2019

@bubenshchykov I contacted ngrok about this issue today. Here is their response:

i think you need to file an issue with the npm module (it's a third party module that we don't maintain). my guess is that it just needs to be updated to sleep for a bit and then retry when it sees that error)

- alan
Founder, ngrok.com

@paton
Copy link

paton commented Jul 17, 2019

Alan's suggestion seems to be inline with #149 which adds this error code to the isRetriable method.

@bubenshchykov
Copy link
Owner

hi @paton , module already handles that:
https://github.com/bubenshchykov/ngrok/blob/master/index.js#L61 - same error message is marked as retriable, then module sleeps for 200ms and retries 100 times max - which gives 20 seconds of total wait time

feel free to increase retries count or sleep time and see if it helps
https://github.com/bubenshchykov/ngrok/blob/master/index.js#L49

@bubenshchykov
Copy link
Owner

@paton yes, there might be a change of error message that screwed the logic up
please add your message and i'll be quick to publish the PR

@paton
Copy link

paton commented Jul 17, 2019

@bubenshchykov

module already handles that:

The code you referenced checks for status code 502. Ngrok is returning a 503, so isRetriable is false despite the 503.

@bn185068
Copy link

bn185068 commented Mar 31, 2021

Hi all, I notice that this was resolved and closed; however, we are experiencing the same issue, and we are running ngrok@3.4.0 in a docker container. Any guidance on what may be continuing to cause this error for us? For context, ngrok works on my local machine perfectly fine. Its only when it gets launched inside the docker container.

@philnash
Copy link
Collaborator

philnash commented Apr 3, 2021

@bn185068 Is there any further information you can provide to help look into this? This has been marked resolved because the library now checks for 503s and continues to retry until ngrok connects.

@bn185068
Copy link

bn185068 commented Apr 6, 2021

@philnash unfortunately, I can't share our codebase. However, I think I may have figured it out. For whatever reason, my global npm env is locked into using ngrok version 2.3.38 despite the fact that my node project is using 3.4.0. I can't get it to upgrade despite running npm i -g ngrok@version.number. This is clearly a different problem than this issue, and I will attempt to resolve on my own. Thanks for responding so quickly! Apologies for the mix up on my end.

@philnash
Copy link
Collaborator

philnash commented Apr 6, 2021

@bn185068 There can be some confusion between the original ngrok executable and this ngrok Node package. The latest version of the ngrok executable is indeed 2.3.38. From what I can see, the executable ngrok function from this package actually points to its locally installed version of the ngrok executable, so I would expect that to be version 2.3.38.

Note, you can also find the underlying version of the ngrok executable from within this package by calling ngrok.getVersion().

Finally, on your existing problem about ngrok not connecting, could it be to do with your Docker config at all? I don't use Docker myself, but could there be an issue with ngrok not being able to make an outbound ssh tunnel through your container? Are you able to successfully start the ngrok executable without using this package?

@bn185068
Copy link

bn185068 commented Apr 7, 2021

@philnash forgive me, but now I'm rather confused. Running ngrok --version in my terminal results in 2.3.38, which makes sense based on what you're saying because that would be the executable. I also have a node project where ngrok is a dependency, and in that project, I just ran ngrok.getVersion() and that version is also 2.3.38. So which ngrok has a version 3.2.3 where this error is fixed per issue #149. Are you saying the node package also uses the ngrok executable, which is why they are both 2.3.38?

For context on the docker question, I'm using a corporate MacBook given to me by my employer. The weird part is that running ngrok http 4000 in a naked terminal works brilliantly. However, when I try to import the package to our node project, build the app into a docker container and run the container on that same corporate MacBook, this error occurs. The corporate MacBook detail is relevant because yesterday I ran the same container on both my personal MacBook and in a cloud env and everything works fine: the container runs, ngrok establishes a tunnel and the app works properly.

So now I'm led to believe there is something strange going on with my corporate laptop with regard to using ngrok in a docker container, but I'm not entirely sure since ngrok does work on the laptop generally speaking.

@philnash
Copy link
Collaborator

philnash commented Apr 7, 2021

Running ngrok --version in my terminal results in 2.3.38, which makes sense based on what you're saying because that would be the executable. I also have a node project where ngrok is a dependency, and in that project, I just ran ngrok.getVersion() and that version is also 2.3.38.

Yes, both of those versions refer to the underlying ngrok executable, the same one you could get by downloading from ngrok.com. The version of the ngrok package you are using will be listed in your package.json (and more accurately in your package-lock.json).

So now I'm led to believe there is something strange going on with my corporate laptop with regard to using ngrok in a docker container, but I'm not entirely sure since ngrok does work on the laptop generally speaking.

Yeah, if you can successfully run the container and connect to ngrok on different hardware, then it sounds like something in the corporate laptop is blocking you. Though I am afraid I am out of ideas as to what it could be.

@bn185068
Copy link

bn185068 commented Apr 8, 2021

I understand now, thank you for your patience and for the clarification. I'll continue to investigate, and if I come across anything that may be helpful to others in the future, I'll post it here.

Cheers! 🍻

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

5 participants