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

https.get seems wonky, cant get it to work realiably #4352

Open
ongspxm opened this issue Mar 4, 2024 · 3 comments
Open

https.get seems wonky, cant get it to work realiably #4352

ongspxm opened this issue Mar 4, 2024 · 3 comments
Labels

Comments

@ongspxm
Copy link

ongspxm commented Mar 4, 2024

Details

im trying to use the telegram bot api. but it doesnt work reliably for me
when i try accessing the same url in curl or browser it can get it reliably

https.get('https://api.telegram.org/botXXXYYYZZZ/getMe', (res)=>{
    res.on('data', console.log);
});

but if i run the same code 9 out of 10 times, i get the following error:

  code: 'ETIMEDOUT',
  [errors]: [
    Error: connect ETIMEDOUT 149.154.167.220:443
        at createConnectionError (node:net:1643:14)
        at Timeout.internalConnectMultipleTimeout (node:net:1702:38)
        at listOnTimeout (node:internal/timers:575:11)
        at process.processTimers (node:internal/timers:514:7) {
      errno: -110,
      code: 'ETIMEDOUT',
      syscall: 'connect',
      address: '149.154.167.220',
      port: 443
    },
    Error: connect ENETUNREACH 2001:67c:4e8:f004::9:443 - Local (:::0)
        at internalConnectMultiple (node:net:1180:16)
        at Timeout.internalConnectMultipleTimeout (node:net:1707:5)
        at listOnTimeout (node:internal/timers:575:11)
        at process.processTimers (node:internal/timers:514:7) {
      errno: -101,
      code: 'ENETUNREACH',
      syscall: 'connect',
      address: '2001:67c:4e8:f004::9',
      port: 443
    }
  ]

and there will be some occasion that it works (just retrying the same code multiple times)

https.get('https://api.telegram.org/botXXXYYYZZZ/getMe', {timeout: 10000}, (res)=>{
    res.on('data', console.log);
});

tried the timeout options and it didnt work too

Node.js version

v21.6.1

Example code

No response

Operating system

linux

Scope

library

Module and version

Not applicable.

@snigdha920
Copy link

snigdha920 commented Mar 8, 2024

I have the same issue, I'm using node-vault to connect to a hashicorp vault. My colleagues have the same code working on their laptop, the same code worked for me before, but now I get:

AggregateError:
    at internalConnectMultiple (node:net:1116:18)
    at afterConnectMultiple (node:net:1680:7)
    at TCPConnectWrap.callbackTrampoline (node:internal/async_hooks:130:17) {
  code: 'ETIMEDOUT',
  [errors]: [
    Error: connect ETIMEDOUT 35.92.220.35:8200
        at createConnectionError (node:net:1643:14)
        at Timeout.internalConnectMultipleTimeout (node:net:1702:38)
        at listOnTimeout (node:internal/timers:575:11)
        at processTimers (node:internal/timers:514:7) {
      errno: -110,
      code: 'ETIMEDOUT',
      syscall: 'connect',
      address: '35.92.220.35',
      port: 8200
    },
    Error: connect EHOSTUNREACH 64:ff9b::235c:dc23:8200
        at createConnectionError (node:net:1643:14)
        at afterConnectMultiple (node:net:1673:16)
        at TCPConnectWrap.callbackTrampoline (node:internal/async_hooks:130:17) {
      errno: -113,
      code: 'EHOSTUNREACH',
      syscall: 'connect',
      address: '64:ff9b::235c:dc23',
      port: 8200
    }
  ]
}
node --version
v21.7.0

I'm on MacOS, Sonoma 14.4

Update: It was my ISP, not a node issue. I connected over personal hotspot instead of wifi and then the call to the same url worked.

@preveen-stack
Copy link
Contributor

sh-3.2$ node --version
v21.6.2
sh-3.2$ cat test.js
https = require('https')
https.get('https://api.telegram.org/botXXXYYYZZZ/getMe', (res)=>{
res.on('data', console.log);
});
sh-3.2$ node test.js
<Buffer 7b 22 6f 6b 22 3a 66 61 6c 73 65 2c 22 65 72 72 6f 72 5f 63 6f 64 65 22 3a 34 30 34 2c 22 64 65 73 63 72 69 70 74 69 6f 6e 22 3a 22 4e 6f 74 20 46 6f ... 5 more bytes>
sh-3.2$ node test.js
<Buffer 7b 22 6f 6b 22 3a 66 61 6c 73 65 2c 22 65 72 72 6f 72 5f 63 6f 64 65 22 3a 34 30 34 2c 22 64 65 73 63 72 69 70 74 69 6f 6e 22 3a 22 4e 6f 74 20 46 6f ... 5 more bytes>
sh-3.2$ node test.js
<Buffer 7b 22 6f 6b 22 3a 66 61 6c 73 65 2c 22 65 72 72 6f 72 5f 63 6f 64 65 22 3a 34 30 34 2c 22 64 65 73 63 72 69 70 74 69 6f 6e 22 3a 22 4e 6f 74 20 46 6f ... 5 more bytes>
sh-3.2$ node test.js
<Buffer 7b 22 6f 6b 22 3a 66 61 6c 73 65 2c 22 65 72 72 6f 72 5f 63 6f 64 65 22 3a 34 30 34 2c 22 64 65 73 63 72 69 70 74 69 6f 6e 22 3a 22 4e 6f 74 20 46 6f ... 5 more bytes>
sh-3.2$ node test.js
<Buffer 7b 22 6f 6b 22 3a 66 61 6c 73 65 2c 22 65 72 72 6f 72 5f 63 6f 64 65 22 3a 34 30 34 2c 22 64 65 73 63 72 69 70 74 69 6f 6e 22 3a 22 4e 6f 74 20 46 6f ... 5 more bytes>
sh-3.2$ node test.js
<Buffer 7b 22 6f 6b 22 3a 66 61 6c 73 65 2c 22 65 72 72 6f 72 5f 63 6f 64 65 22 3a 34 30 34 2c 22 64 65 73 63 72 69 70 74 69 6f 6e 22 3a 22 4e 6f 74 20 46 6f ... 5 more bytes>
sh-3.2$ node test.js
<Buffer 7b 22 6f 6b 22 3a 66 61 6c 73 65 2c 22 65 72 72 6f 72 5f 63 6f 64 65 22 3a 34 30 34 2c 22 64 65 73 63 72 69 70 74 69 6f 6e 22 3a 22 4e 6f 74 20 46 6f ... 5 more bytes>
sh-3.2$ node test.js
<Buffer 7b 22 6f 6b 22 3a 66 61 6c 73 65 2c 22 65 72 72 6f 72 5f 63 6f 64 65 22 3a 34 30 34 2c 22 64 65 73 63 72 69 70 74 69 6f 6e 22 3a 22 4e 6f 74 20 46 6f ... 5 more bytes>
sh-3.2$ node test.js
<Buffer 7b 22 6f 6b 22 3a 66 61 6c 73 65 2c 22 65 72 72 6f 72 5f 63 6f 64 65 22 3a 34 30 34 2c 22 64 65 73 63 72 69 70 74 69 6f 6e 22 3a 22 4e 6f 74 20 46 6f ... 5 more bytes>

on macos 14.3.1 intel with node 21.6.2, I could not reproduce

@valluhub
Copy link

I'm experiencing the same issue with net.connect() inside a Docker container (node:21 image). My docker does not have IPv6 enabled.

The issue seems to be related to a dual-stack IPv4+IPv6 host. In my case it's the WHOIS server at whois.nic.io. If I force net.connect() to use IPv4-only { family: 4 } the problem does not occur.

I would expect the connection be successful using IPv4 if IPv6 fails, but it seems if I let it try IPv6 then IPv4 fails too. Like I mentioned, when I force net.connect() to not use IPv6 it's all fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants