Desync, Timestamp for this request was 1000ms ahead of the server's time
See original GitHub issueJava version : C:\Program Files\Java\jdk1.8.0_152\bin>java.exe -version java version “1.8.0_152” Java™ SE Runtime Environment (build 1.8.0_152-b16) Java HotSpot™ 64-Bit Server VM (build 25.152-b16, mixed mode)
Quite a common error, here is the snippet of code I am using to compare the time between my computer and binance API :
package laby.java;
import com.binance.api.client.BinanceApiClientFactory;
import com.binance.api.client.BinanceApiRestClient;
public class Main {
private static final String APIKEY = "key";
private static final String APISECRET = "secret";
public static void main(String[] args) {
BinanceApiClientFactory factory = BinanceApiClientFactory.newInstance(APIKEY, APISECRET);
BinanceApiRestClient client = factory.newRestClient();
while (true) {
// Checking time between
Long clientTime = java.lang.System.currentTimeMillis();
Long serverTimerTime = client.getServerTime();
System.out.println("Times : client[" + clientTime + "] server[" + serverTimerTime + "] diff[" + (serverTimerTime - clientTime) + "]");
}
}
}
Results:
Times : client[1514132675503] server[1514132675624] diff[121]
Times : client[1514132677246] server[1514132676946] diff[-300]
Times : client[1514132678541] server[1514132677226] diff[-1315]
Times : client[1514132678820] server[1514132677505] diff[-1315]
Times : client[1514132679098] server[1514132677788] diff[-1310]
Times : client[1514132679420] server[1514132678111] diff[-1309]
Times : client[1514132679729] server[1514132678414] diff[-1315]
Times : client[1514132680007] server[1514132678698] diff[-1309]
Times : client[1514132680293] server[1514132678983] diff[-1310]
Times : client[1514132680579] server[1514132679265] diff[-1314]
Times : client[1514132680858] server[1514132679544] diff[-1314]
Times : client[1514132681137] server[1514132679823] diff[-1314]
Times : client[1514132681417] server[1514132680107] diff[-1310]
Process finished with exit code 1
Registry setting is set to update time each ten minutes, it doesn’t change anything:
For your information, I updated the clock time before each attempt :
I am loosing around 1.2 seconds somewhere, and I don’t know where
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
Binance order: Timestamp for this request was 1000ms ahead ...
Binance server time is behind your server time, because Binance servers do not sync often with ntp servers. Workaround: binance.
Read more >Binance error: Timestamp for this request was 1000ms ahead ...
For windows, i opened the time and click de sync the clock with windows server. When i did it, it worked! Before you...
Read more >get_account error "Timestamp for this request was 1000ms ...
Hey I m trying to do this (on python): a = client.get_acount() print(a) and return me this error "Timestamp for this request was...
Read more >timestamp for this request was 1000ms ahead of the server's ...
In this video we are fix the time server error when using python binance library.# time server #Binance API #python binanceit is just...
Read more >How to resolve Binance's Timestamp ahead of Server's time ...
"Binance error: Timestamp for this request is 1000ms ahead of the server's time". At first, I thought I made a mistake when typing...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I just solve this problem using getServerTime() and gap time for example
before
after
But It is need 1 weight more When call the method. If weight is important I will make static time variable and just call only one getServerTime(). I hope this way help you. : )
I put a PR up for this #11. Its been working for a couple days so I think its safe. Not sure if its the best implementation though. Check it out if you want.