Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Solutions For Nonce Error Caused By Threaded API Calls?

I'm making API Calls on Threads. The API requires each call to have Nonce greater then the last call.

I'm generating Nonce using this code:

req['nonce'] = int(time.time()*1000000)

I'm getting errors:

"{u'error': u'Nonce must be greater than 1427495062551856. You provided 1427495062544266.'}".

I believe the cause of the error is slight variations in API request/response times is causing one API request to reach the server ahead of a prior request (that would have a lower Nonce).

Does anyone have a solution for this?

like image 202
Excelsior Avatar asked May 15 '26 19:05

Excelsior


1 Answers

I had that problem when using Poloniex crypto currency exchange API. Some buy or sell calls were hanging for 2 minutes for some reason (you probably could ask Poloniex why it's like that). My calls were asynchronous, so new calls were made without waiting for "hung" calls.

I just re-made these hung calls checking for a "Nonce must be greater than " prefix on error string. You can see the code in my github repo

like image 187
Maciek Łoziński Avatar answered May 17 '26 07:05

Maciek Łoziński