Chris J. Vargo
Chris J. Vargo

Reputation: 2446

Ubuntu Box Sporadically Losing Time with Twitter API

I'm running a digitalocean Ubuntu box, and I am capturing Twitter's search API using python and the oauth2 module. My script works well for long periods of time, but after some time at an apparently random iterations of the script I get this error:

 "code":135,"message":"Timestamp out of bounds."

Several places suggest and confirm that this is a time sync issue with my server and Twitter's API. Some have suggested that the two time's need to be within 30 seconds of each other at all times. Is there anything I can be running, or adding to my python script that would prevent this intermittent time sync problem?

Upvotes: 0

Views: 121

Answers (1)

JumpandSpintoWin
JumpandSpintoWin

Reputation: 187

Update: Digital Ocean publishes a guide on setting up time synchronization for their VPS services. It's the standard NTP setup in an easy to understand format. The original answer did not initiate a forced synchronization for clocks that varied further than ntpd would correct.

Original:

Twitter closely monitors time, as you have discovered. Thankfully, this is a well solved problem in computers.

For ubuntu, just run

sudo apt-get install ntp

which will install the daemon for Network Time Protocol, which will sync your computer's clock with the world. For more information on NTP (if you're curious), see the wikipedia entry for NTP.

Upvotes: 2

Related Questions