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
249 stars 82 forks source link

[UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "(orderbook.50.BTCUSDT,greek) failed to subscribe".] { code: 'ERR_UNHANDLED_REJECTION' } #290

Closed minyongcode closed 11 months ago

tiagosiebler commented 1 year ago

When does this happen? When calling the subscribeV5 function on the websocket client?

Can you provide an example of what parameters you sent when you called this and saw this error? You should probably wrap that function call in a try/catch block, though I'm guessing something is wrong with the parameters you've sent. Need more information here.

Bennch commented 1 year ago

Since today i have the same problem. On my server it works, but on my computer i get error:

UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "(order) failed to subscribe".

Code:

try {
        //wsClient.subscribe(['order']);
        wsClient.subscribeV5(['order'], 'linear');
} catch (error) {
    console.log("Fehler: " + error)
}

This happens even if IP is whitelisted or all IPs allowed...

tiagosiebler commented 1 year ago

subscribeV5 returns a promise, can you try to await wsClient.subscribeV5(['order'], 'linear');? That should give more info on what the exception was. I wonder if there's a new geo-IP ban, since it works fine on the server.

Bennch commented 1 year ago

GEO IP ban must be the answer... I'm located in germany, i hope they dont ban german customers like binance...

tiagosiebler commented 1 year ago

GEO IP ban must be the answer... I'm located in germany, i hope they dont ban german customers like binance...

Does the error improve if you await the wsClient.subscribeV5 inside the/catch? It should have more info on what led to the promise rejection.

Bennch commented 1 year ago

Its the same message "(order) failed to subscribe" but now the whole app doesn't crash. Also i can't get account informations with

const linearClient = new RestClientV5({

tiagosiebler commented 1 year ago

So rest api calls aren't working either for you? Can you provide a more detailed error? There should be some kind of error somewhere, probably from the REST API response. If you can provide that, I can ask my bybit contacts about it.

Bennch commented 1 year ago

Now everything works again. I guess my IP had a timeout...