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:

Listen for Connection Changes

Register a ConnectionListener to receive real-time connection state updates. We recommend adding this on app startup (e.g., in App.tsx) after CometChat.init() completes.
Always remove connection listeners when they’re no longer needed (e.g., on component unmount). Failing to remove listeners can cause memory leaks and duplicate event handling.

Next Steps

WebSocket Management

Manually manage WebSocket connections

All Real-Time Listeners

Complete reference for all SDK listeners

Setup SDK

Install and initialize the CometChat SDK

Key Concepts

Review the fundamental building blocks of CometChat