-
-
Notifications
You must be signed in to change notification settings - Fork 7.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Binance: Timestamp for this request is outside of the recvWindow #936
Comments
Hi! Do you have internet time synchronization enabled in your system clock settings? |
I'm also seeing this error on my end. I'm running on an ubuntu VM and yes, time sync is enabled. |
MacOS here and I have the same problem. My time is sync as well |
Yes, my time is sync as well. |
Does this work for you, guys: // JavaScript
;(async () => {
binance.verbose = true
balance = await binance.fetchBalance ({'recvWindow': 10000000})
console.log (balance)
}) (); # Python
binance.verbose = True
balance = binance.fetch_balance({'recvWindow': 10000000})
print(balance) // PHP
$binance->verbose = true;
$balance = $binance->fetch_balance ({'recvWindow': 10000000});
var_dump ($balance); ? |
Yes this works. It's strange that you need such a huge window for their API. Something's strange going on there... |
@paroxysm apparently, they have time synch issues within their system themselves. The ccxt code for Binance hasn't changed recently, so if they stopped working suddenly because of timing issues, it means their service is experiencing trouble. I notified their team, they usually respond quickly. I guess, they are aware and are working on this already. If you don't mind, I would close this issue for now, because the reason is now mostly obvious. I will update you here, when we have a followup on this from Binance. For now, we can't workaround this issue, if their own time-synch is unstable. Let me know if I can help with anything else. |
From Binance:
Guys, from the above, I guess, it follows, that you need to change the frequency of your time synch updates (set smaller intervals for time polling). You can either do this by googling for it or with 3rd party software. Mac/Linux/FreeBSD/*nix users can change their |
ok |
This helped me. i set sync to each 12 minutes, it work s now |
I added the following to my ntp.conf: But I still get the same recvWindow error. Is this the right way to increase the syncing frequency on OSX? |
@dmeffert need to google for it, for example, see if this helps: https://apple.stackexchange.com/questions/117864/how-can-i-tell-if-my-mac-is-keeping-the-clock-updated-properly |
I get the same error. What can be a correct value for timestamp? I know the format, but not when.. example: ['recvWindow' => 10000000, 'timestamp' => time() + 10000000 ] right? |
You don't need to set it by hand at all. All you need is to create a new key and set up proper time synchronization on your machine to sync time once every 10 minutes.
Nope. The best solution would be to set up time synch and not override their defaults at all. // JavaScript
;(async () => {
binance.verbose = true
balance = await binance.fetchBalance ({'recvWindow': 10000000}) // no override for timestamp
console.log (balance)
}) (); An alternative way would be to enable adjustments for the time difference: // JavaScript
let binance = new ccxt.binance ({
'options': {
'adjustForTimeDifference': true,
'verbose': true, // if needed, not mandatory
'recvWindow': 10000000, // not really needed
},
})
;(async () => {
balance = await binance.fetchBalance ()
console.log (balance)
}) (); Hope it helps. |
working decision is to add parameter
|
Hello i buyed a website project from codecanyon but owner of project didnt reply me. I have just 1 problem about binance api. When i put my binance key and binance secret i got this error. binance {"code":-1021,"msg":"Timestamp for this request is outside of the recvWindow."} I cant see any balance on my website and I have a meeting 2 hours later about this website. I can give cpanel informations. I cant find where should i put your codes. Please someone help me this is very important meeting for me. Thank you |
@seroberto hi! Unfortunately, we can't support the code that we don't write or maintain, especially, without seeing the code itself. CCXT works in that regard and it is free for the users. |
So just can you tell me which code can fix it and where should i put that code? binance-server-time.js |
@seroberto we are not the authors of the code you mentioned, so we can't physically guess how to fix it. It's pretty much like asking any random guy how to fix any random code. |
const binance = new ccxt['binance'] () $opt = [
'timestamp' => $this->nonce (), Sorry for my questions but its really important for me. Should i fix anything one of the this parts? |
@seroberto it's hard to help you without seeing the code, and we are not in charge of it, sorry. Try changing this line: const binance = new ccxt['binance'] () ↓ const binance = new ccxt['binance'] ({ enableRateLimit: true, options: { adjustForTimeDifference: true }}) If that does not help – we won't be able to fix it for you, unfortunately. |
@seroberto it can happen if you used the same key on anither timezone, I read it also in the ccxt docs. For example I have two api keys on binance, one is used on the servers and one is used locally during development, otherwise if you use only one key the nonce could miss its main requirement that is to be an increasing sequence. In particular this happens if the timezones are different. So probably your code works but the issue is on the api key nonce, you probably should use one key for development and one for production. good luck! |
// PHP when i use this code i got this error for this line $balance = $binance->fetch_balance ({'recvWindow': 10000000}); Syntax error, uxpected '{' |
Hello. How did you get 2 api from binance? When i try to create i have only one choose for api on binance. |
@seroberto Change it like so: $balance = $binance->fetch_balance(); However, if you are not familiar with the programming languages, you might run into another problem right away, since using this lib requires programming skills. |
Hi, for example I have two keys now, to add another one I see something like this, I just need to add a label and click create |
I had the same problem on the Mac and turns out my firewall was blocking timed which is Apple's "Time Daemon". I put it into the whitelist and the requests starting working again. "Time Daemon" is a macOS system process that maintains system clock accuracy by synchronizing the clock with reference clocks via technologies like NTP. |
Force-syncing time helped (MacOS)
|
I modified returned responses in Exchange.php to get more information. This is what i get:
The text was updated successfully, but these errors were encountered: