Search⌘ K
AI Features

Break Our Application Like a User (Part II)

Explore how to use acceptance testing to simulate real user disconnections and reconnections in Phoenix real-time applications. Understand how to verify that the application's WebSocket channel reconnects smoothly, preserving seamless user experience despite network interruptions and server restarts.

We'll cover the following...

Internet-related actions

Internet connections are unreliable. Connections can randomly fail when we’re on a laptop or desktop, and it’s more common than it should be to have a low-quality data connection on cell phones. We need to ensure that our application can properly reconnect a user’s connection, even if the page has been open for a long time.

The official Channels JavaScript client handles reconnection attempts for us. It uses a back-off algorithm that starts with frequent retries and waits a few seconds between attempts. If needed, we can change the reconnection algorithm to be more or less aggressive, but the default one will work well for most applications. We’ll execute a test case to ensure that users can reconnect to the store when they become disconnected.

...