tiagosiebler / bybit-api

Node.js SDK for the Bybit APIs and WebSockets, with TypeScript & browser support.
https://www.npmjs.com/package/bybit-api
MIT License
228 stars 78 forks source link

Problem connecting to api.bybit.com #356

Closed Mastero4ek closed 21 hours ago

Mastero4ek commented 1 week ago

Hi all. I can't solve the problem. Help. I already tried changing dns - it didn't help.

IMG_20240625_233221_520 IMG_20240625_233221_627

tiagosiebler commented 6 days ago

This error suggests an issue with your network. Your machine is unable to resolve api.bybit.com to an IP address, so cannot even try to make a request. You will probably also see issues if you try to ping this address in command line, e.g. in a unix system:

ping api.bybit.com

Should give an output similar to:

$ ping api.bybit.com
PING d3d4ij29qlbhtu.cloudfront.net (18.154.22.86): 56 data bytes
64 bytes from 18.154.22.86: icmp_seq=0 ttl=246 time=80.249 ms
64 bytes from 18.154.22.86: icmp_seq=1 ttl=246 time=76.124 ms
64 bytes from 18.154.22.86: icmp_seq=2 ttl=246 time=74.163 ms
64 bytes from 18.154.22.86: icmp_seq=3 ttl=246 time=74.014 ms
64 bytes from 18.154.22.86: icmp_seq=4 ttl=246 time=89.857 ms

If you're getting an error from a simple ping as well, you will need to investigate your network for why it cannot resolve the domain, or find another server that doesn't have this issue. Not something the SDK can fix as it relies on a working network connection.

Mastero4ek commented 5 days ago

Thank you. I'll try to ping. And I'll check the network

RoshOne4 commented 3 days ago

I have the same problem since a few days. I make about 100 requests per hour but about 10 failed with this error. Same problem on local and server.

cause: Error: getaddrinfo ENOTFOUND api.bybit.com
at GetAddrInfoReqWrap.onlookupall [as oncomplete] (node:dns:120:26) {
errno: -3008,
code: 'ENOTFOUND',
syscall: 'getaddrinfo',
hostname: 'api.bybit.com'
}

Trying to ping the bybit server works fine:

$ ping api.bybit.com
PING d3d4ij29qlbhtu.cloudfront.net (18.245.175.5) 56(84) bytes of data.
64 bytes from server-18-245-175-5.cdg55.r.cloudfront.net (18.245.175.5): icmp_seq=1 ttl=249 time=0.412 ms
64 bytes from server-18-245-175-5.cdg55.r.cloudfront.net (18.245.175.5): icmp_seq=2 ttl=249 time=0.445 ms
64 bytes from server-18-245-175-5.cdg55.r.cloudfront.net (18.245.175.5): icmp_seq=3 ttl=249 time=0.516 ms
Mastero4ek commented 3 days ago

I have the same problem since a few days. I make about 100 requests per hour but about 10 failed with this error. Same problem on local and server.

cause: Error: getaddrinfo ENOTFOUND api.bybit.com
at GetAddrInfoReqWrap.onlookupall [as oncomplete] (node:dns:120:26) {
errno: -3008,
code: 'ENOTFOUND',
syscall: 'getaddrinfo',
hostname: 'api.bybit.com'
}

Trying to ping the bybit server works fine:

$ ping api.bybit.com
PING d3d4ij29qlbhtu.cloudfront.net (18.245.175.5) 56(84) bytes of data.
64 bytes from server-18-245-175-5.cdg55.r.cloudfront.net (18.245.175.5): icmp_seq=1 ttl=249 time=0.412 ms
64 bytes from server-18-245-175-5.cdg55.r.cloudfront.net (18.245.175.5): icmp_seq=2 ttl=249 time=0.445 ms
64 bytes from server-18-245-175-5.cdg55.r.cloudfront.net (18.245.175.5): icmp_seq=3 ttl=249 time=0.516 ms

I managed to solve the problem, but not completely. I called my Internet connection provider and they set up a connection to api.bybit.com. But if there are too many requests in a short period of time, sometimes this error may appear

tiagosiebler commented 2 days ago

I have the same problem since a few days. I make about 100 requests per hour but about 10 failed with this error. Same problem on local and server.

cause: Error: getaddrinfo ENOTFOUND api.bybit.com
at GetAddrInfoReqWrap.onlookupall [as oncomplete] (node:dns:120:26) {
errno: -3008,
code: 'ENOTFOUND',
syscall: 'getaddrinfo',
hostname: 'api.bybit.com'
}

Trying to ping the bybit server works fine:

$ ping api.bybit.com
PING d3d4ij29qlbhtu.cloudfront.net (18.245.175.5) 56(84) bytes of data.
64 bytes from server-18-245-175-5.cdg55.r.cloudfront.net (18.245.175.5): icmp_seq=1 ttl=249 time=0.412 ms
64 bytes from server-18-245-175-5.cdg55.r.cloudfront.net (18.245.175.5): icmp_seq=2 ttl=249 time=0.445 ms
64 bytes from server-18-245-175-5.cdg55.r.cloudfront.net (18.245.175.5): icmp_seq=3 ttl=249 time=0.516 ms

@RoshOne4 your scenario sounds like it's mostly working. You've identified ping is normally OK and able to resolve an IP, but sometimes it fails to resolve. You would also need to look at the DNS your machine is using to understand why it fails to resolve that IP sometimes. Perhaps the DNS is unstable or has other issues. You could try other DNS servers, such as those from OpenDNS or google, or you can try talking to your current DNS provider (ISP or hosting provider, depending where you are testing).

Generally speaking a DNS issue is outside the control of an SDK such as this one. The SDK simply asks your machine to make a request to api.bybit.com, it's up to your machine to talk to your DNS to get an IP address for the domain. If that step fails for some reason, you will see ENOTFOUND.