stavros.3p
stavros.3p

Reputation: 2324

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.

Upvotes: 5

Views: 25872

Answers (4)

Jôsùå
Jôsùå

Reputation: 21

The main problem is that, the server expect a 64 bit long unix time stamp, and you most likely send a 32 bit long one, maknig a huge diference, which explain why a huge delay "solves" the problem

Upvotes: 0

Sive.Host
Sive.Host

Reputation: 85

With PHP try $millitime = round(microtime(true) * 1000);

Upvotes: 1

anas melepeediakkal
anas melepeediakkal

Reputation: 49

update api request of python-binance library file path binance/client.py add additional param  recvWindow



def futures_create_order(self, **params):
        """Send in a new order.

        https://binance-docs.github.io/apidocs/futures/en/#new-order-trade

        """
        params['recvWindow'] = 100000000
        print('data params',params)
        return self._request_futures_api('post', 'order', True, data=params)

Upvotes: -1

xalien
xalien

Reputation: 173

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.

Upvotes: 6

Related Questions