Make the tunnel more stable with this one simple hack ✨

The Forge tunnel uses ngrok to connect the Forge backend to your local development server. However, ngrok only allows sessions of up to two hours and rate-limits traffic for anonymous users. When you reach one of these limits, you often have to restart the tunnel. :weary:

It turns out that you can remove the session limit and increase the rate limits by signing up for a free ngrok account (or using a paid account) and modifying a file in the tunnel package.

Note about Docker❗

The instructions below only work if you are using the tunnel without Docker. The hack should also work for the dockerized tunnel, but you would have to create a custom image based on atlassian/forge-tunnel and force the CLI to use the custom image instead of the latest version from the Docker Hub registry.

If you are using macOS or Linux, run which forge to find the install location of the CLI. For the output <path>/bin/forge, the file you need to modify is <path>/lib/node_modules/@forge/sandbox-tunnel/node_modules/@forge/tunnel/config/ngrok.yml. Add the line authtoken: <token>, replacing <token> with your ngrok Authtoken.

You can verify that the hack is working by opening http://localhost:4040 when the tunnel is running. There should be no warning message about the session limit and your Authtoken should be shown on the status page.

15 Likes

oddly, I get this far:
<path>/lib/node_modules/@forge/sandbox-tunnel
and don’t find the sandbox-tunnel directory

Running on
$ forge --version
6.4.2

I see now my cli is fairly out of date… will update and try again.

@jeffryan Have you installed the @forge/sandbox-tunnel package, as described here: Quick tip: Tunneling without Docker (useful for Apple Silicon / M1)?

1 Like

no actually - I wasn’t aware of that. We’ve just been running in docker and it’s been pretty bad. Does that package work on a intel mac?

The package should be platform independent. :+1:

I saw the comments in the package regarding cui invocations still requiring docker. Can we use that and still get a more reliable tunnel via the ngrok token?

I’m not in the Client-side UI kit EAP, but I’ll try to make it work once I have access.

Sorry, I was referring to Custom UI calling into the server using invoke calls. We aren’t using Client-side UI kit yet either.

Custom UI and resolvers are working perfectly. :+1:

1 Like

Anyone struggling with the @forge/cli update to 6.10.0 and the local tunnel.

This “hack” also solves problems described here: Error ERR_NGROK_120 (ngrok version not supported) when attempting to run tunnel

Thanks Christian!

2 Likes