Handling Disconnects

Any stateful conversation between a client and server must handle data that gets out of sync. This problem can happen with unexpected disconnects, or a broadcast that isn’t received while a client is away. We need to handle both cases. Let’s find out how.

Our JavaScript client can disconnect and reconnect for a number of different reasons. Our server might be restarted, a rumbler might drive under a bridge, or our Internet connection may just be poor. We simply can’t assume network reliability when designing our real-time systems. Fire up your server and visit one of your videos. Post a few annotations and then kill the server in your terminal. The client immediately begins trying to reestablish a connection using exponential ...

Get Programming Phoenix 1.4 now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.