Skip to main content
When you instantiate a client, a realtime connection is established and maintained with Ably. You can interact with the connection using the ChatClient.connection object to monitor a client’s connection status.

Connection Statuses

A connection can have any of the following statuses: Use the status property to check which status a connection is currently in:

Monitor Connection Status

Register a listener to monitor connection status changes:

Handle Discontinuity

If a client briefly loses connection to Ably, for example when driving through a tunnel, the SDK will attempt to recover the connection. If the disruption lasts for less than 2 minutes, then on reconnection the SDK will automatically reattach to any rooms and replay any missed messages. During periods of discontinuity greater than 2 minutes then you will need to take steps to recover any missed messages, such as by calling history. The Chat SDK provides an onDiscontinuity() handler exposed via the Room object to assist with this:

Next Steps