I am trying to make a request using this code:
public JsonObject account() throws BinanceApiException {
return (new Request(baseUrl + "v3/account"))
.sign(apiKey, secretKey, null).read().asJsonObject();
}
but I get this error:
BinanceApiException: ERROR: -1021, Timestamp for this request is outside of the recvWindow.
I know that it has something to do with the time synchronization between my computer and the server. I don't get this error every time I run this code. In the past I solved this error by going to Windows settings, Date and Time, Internet Time Settings and synchronize my time to time.windows.com.
Looks like a duplicate of Binance API Error: {"code":-1021,"msg":"Timestamp for this request is outside of the recvWindow."}.
You need to synchronize time on your computer with Binance rather than with time.windows.com. You can use https://binance-docs.github.io/apidocs/spot/en/#test-connectivity Check Server Time endpoint:
GET /api/v3/time
Another possible reason (at least I faced it) - execution of request in debug mode step by step.
Default recvWindow is 5 seconds. You can also override it if you need.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With