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:
StatusDescription
initializedA connection object has been initialized but not yet connected.
connectingA connection attempt has been initiated.
connectedA connection exists and is active.
disconnectedA temporary failure condition when no current connection exists.
suspendedA long term failure condition when no current connection exists because there is no network connectivity.
closingAn explicit request by the developer to close the connection has been sent.
closedThe connection has been explicitly closed by the client.
failedThis status is entered if the SDK encounters a failure condition that it cannot recover from.
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

Build docs developers (and LLMs) love