ccxt / ccxt

A JavaScript / TypeScript / Python / C# / PHP cryptocurrency trading API with support for more than 100 bitcoin/altcoin exchanges
https://docs.ccxt.com
MIT License
32.5k stars 7.47k forks source link

Bybit Rate Limit Exceeded on WS with enableRateLimit on. #16412

Open kingkong404 opened 1 year ago

kingkong404 commented 1 year ago

Operating System

No response

Programming Languages

JS

CCXT Version

2.5.70

Description

Getting a rate limit exceeded message freqently on bybit while having enableRateLimit set to true. I believe this is happening while listening to / calling bybit.watchOrders() Server restart seems to fix the issue.

  RateLimitExceeded  bybit GET https://api.bybit.com/asset/v3/private/coin-info/query?api_key=XXX&recv_window=5000&timestamp=XXX&sign=XXXX 403 Forbidden <HTML><HEAD>
 <TITLE>Access Denied</TITLE>
 </HEAD><BODY>
 <H1>Access Denied</H1>

 You don't have permission to access "http&#58;&#47;&#47;api&#46;bybit&#46;com&#47;asset&#47;v3&#47;private&#47;coin&#45;info&#47;query&#63;" on this server.<P>
 Reference&#32;&#35;18&#46;2db01302&#46;1673340371&#46;5973a488
 </BODY>
 </HTML>```

### Code

   export const bybit = new ccxtpro.bybit({ apiKey: process.env.BYBIT_API, secret: process.env.BYBIT_SECRET, enableRateLimit: true, })

pcriadoperez commented 1 year ago

Hi @kingkong404 , I am having trouble to reproduce this on my side. Are you doing lots of orders when running watchOrders? Maybe you can provide the script you are running and a verbose output?

Also by the message error it looks like it could be more an issue of permissions than a rate limit exceeded?

kingkong404 commented 1 year ago

Hi @kingkong404 , I am having trouble to reproduce this on my side. Are you doing lots of orders when running watchOrders? Maybe you can provide the script you are running and a verbose output?

Also by the message error it looks like it could be more an issue of permissions than a rate limit exceeded?

Hi @pcriadoperez after some more testing I believe the issue happens when 2 web sockets are open potentially. The situation in which it is occurring is on server boot after a restart.

Example: Server working fine with Bybit WS for watch orders Server restarts Tries to create a new Bybit WS for watch orders but creates error as likely the prior Bybit WS was not properly closed on server restart. Force restart of server again fixes this.

alanwu4321 commented 1 year ago

Same issue - rate limit from watchOrders - looks like it's calling https://api.bybit.com/v5/asset/coin/query-info?