question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Timestamp 1000ms error with useServerTime = true for long-running script

See original GitHub issue

Title

  • bug: useServerTime not working as expected

Short Description:

  • Timestamp 1000ms after server time with useServerTime = true after running script for 3 days.

Platform:

  • windows

node version:

  • 9.11

Long descrption

  • Timestamp 1000ms after server time with useServerTime = true after running script for 3 days - is it possible running for a long time slowly desynchronizes over time?
  • Error occurred on a signed order request to start a new order after one order had just filled - is it related to doing back-to-back requests, or because I did a request immediately after receiving the ws.executionUpdate packet?

code

binance.options({
	APIKEY: '...',
	APISECRET: '...',
	useServerTime: true,
	test: false
});
//... BinanceBroker.js class
	openOrder: function(order) {
		var that = this;
		//... Prepare and track order, do quantity and price filters
		var options = {
				type: 'LIMIT',
				newOrderRespType: 'ACK',
				newClientOrderId: order.clientId
			};
		//... func will equal binance.buy or binance.sell, or throw.
		return new Promise((resolve, reject) => {
			func(order.pair, amount, price, options, (error, response) => {
				if (error) {
					var body = JSON.parse(error.body);
					console.error('[Binance] ['+order.pair+'] ' + body.msg);
					throw error;
				}
				order.id = response.orderId;
				resolve(order);
			});
		});
	},

result

Timestamp 1000ms past server time error.

thank you

  • No, thank YOU!

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
TomKrcmarcommented, Apr 29, 2018

It’s been 5 days now and I haven’t gotten the error, so this does seem to be the best workaround to mitigate the issue.

Further protections on my side like gracefully handling this error and repeating my request, on the off-chance it still happens, also has me sleeping sounder at night.

Thanks to jaggedsoft and best of luck.

1reaction
jaggedsoftcommented, Apr 23, 2018

I think the real solution here is to sync your server time or set your system to auto-sync the time once or twice per day

Here is one easy solution I can think of

binance.options({
	APIKEY: '...',
	APISECRET: '...',
	useServerTime: true
});

setInterval(function() {
	binance.useServerTime();
}, 8 * 60 * 60 * 1000); // Call this function every 8 hours
Read more comments on GitHub >

github_iconTop Results From Across the Web

Binance order: Timestamp for this request was 1000ms ahead ...
It seems that the recvWindow of 60000 is still not sufficient (but it may not exceed 60K). I still get the same error....
Read more >
node-binance-api - Github Plus
Timestamp 1000ms error with useServerTime = true for long-running script. Title. bug: useServerTime not working as expected. Short Description: Timestamp ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found