Problems with Server Time on Clients


#1

Hello,

I have created a web-app that resembles a timetabling system similar to those of buses’.
The app is straightforward; client fetches server time, compares it with times in a collection, and displays the relevant content.

For now, I have connected about 20 screens to the app (via browsers, via LAN using IP address). Ideally, I want the browsers to show the server time, which I have done via methods on the server and calling them on the client’s main body.

When the server is running, everything runs as it supposed to. However, if for some reason the server crashes, and I run the app again via “meteor” command, when every screen refreshes, the clients’ times go crazy; I would imagine that the clients have cached in times and when it tries to override with the server time, the browser tries to get both the old and the new server time which causes activations of the wrong timetable slots.
This eventually causes the server to just stop working, without giving me an error! Not on the console, nor on the browser’s console.

I have been going crazy trying to debug this.
The only way I could get the server back up is by turning off the browsers on those screens, and then connect them one by one, so I know for a fact that it is a traffic issue, but just don’t know how to solve.

Can anyone point me in the right direction, please? Very much appreciated!

P.S after some research, I got introduced to the TimeSync package, but I was unsuccessful in implementing it as I haven’t had a proper example to try and understand it; I am very much new to Meteor and javascript overall.


#2

I hope this is in development, because you should not be running a production application with the meteor command. If your server is crashing, you have bigger problems.

Keeping the client in time sync with the server is not a trivial task. Variable latency needs to be considered, and mizzao:timesync (which I think is what you’re referring to) is a good solution.


#3

Yes it’s still in development. And yes that precisely the package.

What would a small hh:mm:ss example that syncs clients and server side? Thank you for taking the time!