Design for Unreliable Connections
Clients connect to our real-time application using a long-lived connection. The client’s connection can close or fail at any point; we need to consider this and write code to recover from this when it happens.
There are certainly expected reasons for a connection to disconnect, such as a user leaving the application, changing pages, or closing their laptop while the application is loaded. There are also more unpredictable reasons that cause a connection to (erroneously) disconnect. A few examples of this are:
-
A client’s internet connection becomes unstable and drops their connection without any other changes.
-
A bug in the client code causes it to close the connection.
-
The server restarts due to a routine deploy ...
Get Real-Time Phoenix now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.