ngrok-javascript
ngrok-javascript copied to clipboard
Takes a minute to start
SDK Version
1.4.1
What happened?
The library takes a lot of time to start.
Consider the following script:
import ngrok from '@ngrok/ngrok';
ngrok.consoleLog('TRACE');
try {
const listener = await ngrok.forward({
addr: '8080',
authtoken: '…',
});
console.log(listener.url());
} catch (error) {
console.error(error);
}
I'm getting the following log output:
DEBUG log - add_parsable_certificates processed 1 valid and 0 invalid certs
(HANGS HERE FOR A LONG TIME)
DEBUG log - No cached session for DnsName("connect.ngrok-agent.com")
DEBUG log - Not resuming any session
DEBUG log - Using ciphersuite TLS13_AES_128_GCM_SHA256
DEBUG log - Not resuming
DEBUG log - TLS1.3 encrypted extensions: []
DEBUG log - ALPN protocol is None
DEBUG muxado::heartbeat - sending heartbeat
DEBUG muxado::heartbeat - waiting for response
DEBUG muxado::heartbeat - got response
DEBUG ngrok::internals::raw_session - decoded rpc response
INFO ngrok_javascript::session - Session created "…", with auth token
DEBUG muxado::typed - read stream type
DEBUG muxado::stream_manager - got none from stream, trying to send a fin
DEBUG muxado::stream_manager - removing stream and sending fin
DEBUG ngrok::internals::raw_session - decoded rpc response
INFO ngrok_javascript::listener - Created listener "…" with url "https://xxx.ngrok-free.app"
DEBUG muxado::stream_manager - got none from stream, trying to send a fin
DEBUG muxado::stream_manager - removing stream and sending fin
https://xxx.ngrok-free.app
Error logging to javascript function: Error { status: GenericFailure, reason: "Closing", maybe_raw: 0x0 }
I'm running it under Linux. The ngrok binary (installed from apt) works fine if I use it directly.
What could be the reason for this? Thank you.
Okay, the fact that it's closing is caused by the script stopping execution. Don't know why the library is not keeping the process running, but this is yet another story.
I'm more concerned with the fact that it takes a whole minute to start. The ngrok binary starts in a second. Would really appreciate some tips.
@slavafomin Are you still seeing this? We've just published a new version of the SDK, and while I'm not personally seeing this, but I'd love to know if you're still experiencing it. This may be something I'm not seeing due to my proximity to the nearest DC or something
I'm seeing something similar. The cli runs immediately but the js version often (not always) hangs for at least 60s.
I get the following in the logs (using 1.5.1 on macos, node 23.11.0):
DEBUG log - add_parsable_certificates processed 1 valid and 0 invalid certs
about 60s later...
DEBUG log - No cached session for DnsName("connect.ngrok-agent.com")
DEBUG log - Not resuming any session
TRACE log - Sending ClientHello Message { ...
Update: Now it's running fast again, it seems to be intermittent.
@meleyal To clarify: you're seeing it running fast again consistently, or you've been seeing it sometimes fast, sometimes slow?
@bmpngrok sometimes fast, sometimes slow.