How can I work around "ngrok tunnel took too long to connect"?

258 Views Asked by At

I have a React Native project I'm a part of. We use Expo and for various reasons I can't debug over the local network and instead need to use the tunnel feature. I've created a script that starts the project with the following code:

expo start --tunnel

When this runs successfully, the option to open the app will appear on my Expo Go app on my phone and I can launch it. In this way I've successfully been able to run and debug the project many times. However, recently, I get the following much more often:

Starting project at [source path]
Starting Metro Bundler
CommandError: ngrok tunnel took too long to connect.

I can retry starting the project for minutes and minutes and minutes and never get it to start. Then, other days, I can get it to start with only a few tries. I have two ideas as to how I could work around this, but no idea how to actually go about either of them.

Idea 1: Increase the timeout

Watching the command execute, the timeout for ngrok seems to only be a about 10 seconds. Ideally I could just increase this somehow. Since the code does work on occasion, it's very likely just a timeout error.

The problem is I'm not very familiar with any of these tools, and I can't find any file in the project structure which contains configuration for ngrok. I can't find any way to change the timeout.

Idea 2: "Run ngrok manually"

I've seen a few suggestions in my research on this issue, which say to download ngrok and start the tunnel through that separate tool. I've downloaded it, but I have no idea what parameters I need to supply to replicate the tunnel created by Expo.

Again, I can't find any config files in the project which would seem to supply these parameters.

1

There are 1 best solutions below

0
David Conlisk On

I am using ngrok in a corporate environment which is controlled by Netskope. I did the following:

  • install ngrok using chocolatey nuget: choco install ngrok
  • run ngrok diagnose
  • show the output to my network engineer who could then use the information to allow the access required.

Running npx expo start --tunnel now works reliably (for now)

The settings that were updated are:

ssl do not decrypt for *.ngrok-agent.com, *.equinox.io, *.ngrok.com, cloud.google.com