zhouaini528 / binance-php

Binance API Like the official document interface, Support for arbitrary extension.
MIT License
107 stars 43 forks source link

Timestamp for this request is outside of the recvWindow #51

Open blackcatt opened 1 year ago

blackcatt commented 1 year ago

Sometimes binance responds

{"code":-1021,"msg":"Timestamp for this request is outside of the recvWindow.","_method": ...

Looks like my server time is wrong. But it's ok (Debian timesyncd says system clock is in sync: yes) The request may be taking too long. StackOverflow users recommend increasing recvWindow - but how? Zhouaini528 maybe you have smart ideas about this error ?

zhouaini528 commented 1 year ago
$binance->trade()->postOrder([
      'symbol'=>'BTCUSDT',
      'side'=>'SELL',
      'type'=>'LIMIT',
      'quantity'=>'0.001',
      'price'=>'80000',
      'timeInForce'=>'GTC',

      //The value cannot be greater than 60000
      'recvWindow'=>'60000'
  ]);
MarioOlivera commented 1 year ago

@zhouaini528 This can be applied to all methods right? For example, in my case I had this error when obtaining the account data.