Closed pixtron closed 4 years ago
Hey @pixtron are you still using this? I've tried your wrapper and it generally works, but sometimes, rarely, I see this issue too:
{
"ret_code": 10002,
"ret_msg": "invalid request, please check your timestamp and recv_window param. req_timestamp: 1579005481769 server_timestamp: 1579005480587 recv_window: 5000",
"ext_code": "",
"result": null,
"ext_info": null,
"time_now": "1579005480.578442"
}
@tiagosiebler do you see that error on the livenet or on the testnet?
Livenet, I think it might only be immediately after instancing RestClient then calling getUserLeverage() immediately after, but I haven't implemented other parts of this yet, still hooking up websockets.
Are you using this live? Do you see it happen with livenet at all? In case it's useful, this module for binance hasn't seen any drift issues - not sure if that's thanks to binance or how this module handles it: https://github.com/zoeyg/binance/blob/master/lib/rest.js#L83
So from more testing I think this may be a race condition. If I call getUserLeverage() almost immediately after instancing RestClient, the issue happens maybe 80% of the time.
If I delay by one second, I don't see this at all. At least not so far...
In case it's useful, this module for binance hasn't seen any drift issues - not sure if that's thanks to binance or how this module handles it: https://github.com/zoeyg/binance/blob/master/lib/rest.js#L83
This module does basically the same "time synchronisation" as the module you mention.
req_timestamp: 1579005481769 server_timestamp: 1579005480587 recv_window: 5000
What i can see in your error message above is, that the timestamp of the request is 1182 ms ahead of the servers timestamp.
After some testing on my local client, i was able to reproduce the issue randomly (~30% on livenet). Looks like the livenet discards a request if client timestamp is > 1000ms ahead of server timestamp, whereas on the testnet this might be >2500ms.
Turns out the calculation of the offset was wrong. I fixed that in e5fd04a. @tiagosiebler could you check if that change resolves the issue for you as well?
Sweet, thanks! Can you publish the update via npm?
Just published v1.0.3 to npm.
Nice, so far so good - can't reproduce it anymore. Thanks for fixing!
Authenticated rest requests to the testnet randomly fail with the error message
Also websocket authentication fails randomly with a 401 response.