ngrok / ngrok-javascript

Embed ngrok secure ingress into your Node.js apps with a single line of code.
https://ngrok.com
Apache License 2.0
86 stars 17 forks source link

GenericFailure - tls handshake error #137

Closed deejaybill closed 1 month ago

deejaybill commented 2 months ago

Hi,

I've got this error recently with the @ngrok/ngrok@1.2.0 with Node.js 21.7.3

Node.js web server at 8080 is running...
node:internal/process/promises:289
            triggerUncaughtException(err, true /* fromPromise */);
            ^

[Error: failed to connect session: tls handshake error] {
  code: 'GenericFailure'
}

Node.js v21.7.3

Even with the quick start sample that you can find on this page, is enough to get the same error: https://dashboard.ngrok.com/get-started/setup/nodejs

I'm using the authorization token and as a fallback, I've switched back to the Windows agent that works fine.

bobzilladev commented 2 months ago

Hello, thanks for writing in! Can you tell us more about your environment (type of machine, operating system and kernel version, etc)? Are you running the linked example code exactly?

When this has happened before it has been an issue with system libraries on the device, a workaround for which is compiling ngrok-javascript on the device itself rather than using the pre-compiled published versions. If you are comfortable trying that, it requires a working rust compiler and node setup, after which yarn install then yarn build should bake a binary optimized for the local environment.

Looking forward to hearing back!

deejaybill commented 2 months ago

Hi,

here are a few details about my environment.

Microsoft Windows 10 Pro
10.0.19045 Build 19045

AMD Ryzen 7 2700
Physical Memory (RAM)   64,0 GB

Node 21.7.3
Visual Studio Code 1.88.1

package.json (ngrok installed via npm 10.5.2)

{
  "name": "ngrok",
  "version": "1.0.0",
  "main": "index.js",
  "author": "",
  "license": "ISC",
  "description": "",
  "dependencies": {
    "@ngrok/ngrok": "^1.2.0"
  }
}

index.js

const http = require('http');
const ngrok = require('@ngrok/ngrok');

// Create webserver
http.createServer((req, res) => {
    res.writeHead(200, { 'Content-Type': 'text/html' });
    res.end('Congrats you have created an ngrok web server');
}).listen(8080, () => console.log('Node.js web server at 8080 is running...'));

// Get your endpoint online
ngrok.connect({ addr: 8080, authtoken_from_env: true })
    .then(listener => console.log(`Ingress established at: ${listener.url()}`));

Command to run node from the bash inside the visual studio code:

NGROK_AUTHTOKEN=### node index.js

Am I missing something?

bobzilladev commented 2 months ago

Nothing looks amiss with the code here. I was able to run it on both Windows 11 Home 23H2, Windows Server 2016 Datacenter 1607, Windows Server 2019 Datacenter 1809 and Windows Server 2022 Datacenter 21H2 machines.

The generic TLS handshake error is likely an issue with the pre-built code not working well with the crypto libraries on the local machine. In cases like that building the SDK locally will usually solve the issue, if you want to attempt going that route. Since the golang agent is working it's unlikely to be a network issue. Another possibility is trying to run the python SDK, but that is built on the same github runner machines and may run into the same error.

bobzilladev commented 1 month ago

We'll go ahead and close this ticket out, feel free to reopen if you need help with a local build, or if any more information becomes available. Thanks for writing in!