-
-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dealing with: "invalid request, please check your server timestamp or recv_window param" #206
Comments
Your system time is used as part of the auth mechanism to generate the signature. The server uses it to check that your request was sent less than x seconds ago (your recv_window). If your network is struggling or your system time is slightly out of sync, this can happen very often. More detailed explanation here: Most of the time the fix is getting your system time updated through a time service, using either ntp in unix environments or something like atomic clock on windows. You can increase the default recv window to allow for more time, but it's better to do the time sync first. |
@tiagosiebler Thank you for your answer. Could it be because of parallel code execution? |
True, if you're already actively keeping your system clock in sync with a time service this should be less likely... I don't think parallel execution should affect this. The timestamp is freshly taken per request at the time of the request. Which version of the connector are you using? There used to be a time sync feature enabled by default. This was meant to reduce the chances of something like this happening, but I've disabled it by default a few versions ago as it seems to have caused timestamp/recvwindow errors sometimes from overestimating latency. If by any chance you haven't updated in a while, I would try updating to the latest version and seeing if you're noticing this happen. If by any chance you've got this old mechanism turned on via the Otherwise, I would keep an eye on various metrics relating to your system vs server time. Here's an example with the spot client, although the linearclient also exposes a server time api call: The "diff" parts should be quite low (500ms or less). I wonder if these numbers are higher for you when you're seeing these timestamp errors? |
Thank you for your fast answer. I added a I'm going to let you know when I will have more data or if this is reproduced with the latest version. |
Interesting, the end time is quite close, so is this a long delay from the getWalletBalance route? |
It shouldn't. If time sync was turned on, it makes its own request to the time endpoint at intervals, and checks the turnaround on that request. Unless your hanging get wallet balance request is also causing bybit to take longer than normal on the time request, even if it's a separate request started after... But either way time sync is turned off by default now unless you pass |
Nope didn't pass any options : this.client = new LinearClient({
key: this.account.bybitApiKey,
secret: this.account.bybitApiSecret
}); I just got the issue again on my main project where I refresh the let start = Date.now();
let res = await this.client?.getWalletBalance();
let end = Date.now();
if (end - start > 1000){
console.log(`[TIME]: getWalletBalance: ${end - start}ms`);
} Here is the output of the
|
I experienced this issue. The fix is easy, and it does have everything to do with the system clock. It's not an error with the API. @oom- commented that he had his system clock set to Atomically Sync to time.windows.com Unfortunately, time.windows.com sucks. Open up your Date/Time settings in Windows, and change your Internet Time sync to: This is an atomic clock time server of Physikalisch-Technische Bundesanstalt (PTB), a world-renowned research institution in Braunschweig, Germany. As soon as I made this switch, every request executed seamlessly. |
I'm going to pin this, because it's a very common problem to have (it's not necessarily obvious how important it is for your time to be set precisely) and there's a lot of useful suggestions here for anyone with the same problem. |
I will also close this, but if you have other suggestions that helped you identify & fix what was causing this in your system, please keep contributing them. Thank you @JayWiseFree for your comment as well. |
Sorry for the delay I have been really busy these past weeks. One of my colleagues made his own code and got the same error on: VPS (Unix) and his local computer (Windows11). So here is was I have already done: The APP lagging investigation
But when the error happened, no latency was displayed on the
-----> Conclusion 1: This error is not caused by app latency. <-----
The Network lagging investigation
Example of a good packet: (timespan = send time) Example of a wrong packet: (timespan != send time) -----> Conclusion 2: There is definitely something wrong, and it seems to be related to the network or the capacity of NodeJS to send the packet on the network. <-----What's next ?So basically there are multiple questions requiring an answer:
I'm now planning to measure the time of each part of the request (see below) and try to exclude the DNS resolution/lookup from the list above. If it's not the DNS, I will rewrite I will let you know. @tiagosiebler (I'm going to post here the advancements of the investigations if it's fine for you, maybe I will find something we could report to Bybit team.) Appendice
|
I found out why the error was showing up faster on my VPS (after a few minutes of uptime). Going to rerun Going to run the testing script again and see if the error shows up again... |
After starting my robot I'm always getting this error after a while:
It solves by itself by retrying multiple times.
I suppose the time is sometime unsync ?
The text was updated successfully, but these errors were encountered: