How can we reconnect to SendBird servers if there's a network issue?

If there’s a network issue and the WebSocket connection is lost, the Chat SDK with local caching can temporarily keep unsent messages in the local cache and automatically resend them when the connection is reestablished. This is called auto resend. For example, if a user sends a message but the WebSocket connection is lost before the message is sent, the Chat SDK marks the message as pending and stores it locally. When the connection is reestablished, the SDK automatically resends the pending message.

Another example is when a file message is sent but the attached file couldn’t be uploaded to the Sendbird server due to a network issue. The Chat SDK handles the file message as a pending message and adds it to the queue for auto resend. When the network connection is reestablished, the SDK attempts to resend the message.

In both cases, the SDK constantly communicates with the Sendbird server and fetches data through synchronization to prevent gaps in messages or channels. If a huge gap is detected, the SDK discards the existing message collection and creates a new one.