ChatClient.connection object to monitor a client’s connection status.
Connection Statuses
A connection can have any of the following statuses:| Status | Description |
|---|---|
initialized | A connection object has been initialized but not yet connected. |
connecting | A connection attempt has been initiated. |
connected | A connection exists and is active. |
disconnected | A temporary failure condition when no current connection exists. |
suspended | A long term failure condition when no current connection exists because there is no network connectivity. |
closing | An explicit request by the developer to close the connection has been sent. |
closed | The connection has been explicitly closed by the client. |
failed | This status is entered if the SDK encounters a failure condition that it cannot recover from. |
status property to check which status a connection is currently in:
- Tab Title
- Tab Title
- Tab Title
- Tab Title
Monitor Connection Status
Register a listener to monitor connection status changes:- Tab Title
- Tab Title
- Tab Title
- Tab Title
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 anonDiscontinuity() handler exposed via the Room object to assist with this:
- Tab Title
- Tab Title
- Tab Title
- Tab Title
Next Steps
- Learn about rooms
- Explore message features
- Understand presence
