Skip to main content
The CometChat SDK maintains a WebSocket connection to CometChat servers for real-time events. You can check the current connection state and listen for changes — useful for showing connectivity indicators in your UI or queuing operations while offline. When the connection drops, the SDK automatically attempts to reconnect, cycling through disconnectedconnectingconnected.

Connection States

Get Current Status

Use getConnectionStatus() to check the current connection state at any time:
The method returns one of the following values:
  1. CometChatWSState.connected (connected)
  2. CometChatWSState.connecting (connecting)
  3. CometChatWSState.disconnected (disconnected)
  4. CometChatWSState.featureThrottled (featureThrottled)

Listen for Connection Changes

Register a ConnectionListener to receive real-time connection state updates. We recommend adding this on app startup after CometChat.init() completes.

ConnectionListener Events

Always remove connection listeners when they’re no longer needed (e.g., on widget dispose or navigation). Failing to remove listeners can cause memory leaks and duplicate event handling.

Remove Connection Listener

Know more about CometChat SDK connection behaviour click here

Next Steps

Connection Behaviour

Understand how CometChat SDK manages WebSocket connections

Login Listeners

Monitor user login and logout events in real-time

All Real-Time Listeners

Complete reference for all SDK listeners

Setup SDK

Install and initialize the CometChat SDK