Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Timestamp for this request is outside of the recvWindow

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.

like image 403
Student Avatar asked Oct 16 '22 14:10

Student


1 Answers

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.

like image 154
xalien Avatar answered Oct 29 '22 15:10

xalien