Skip to content
Back

Realtime Disconnects and Error: INVALID_STATE_ERR

  • 1
  • 2
  • Databases
  • Android
  • Apple
  • React Native
  • Realtime
Luis P.
7 Jul, 2025, 00:59

Hi Support, we are still experiencing the issue and we are a subscriber on your platform under the account of charlesbcalague@gmail.com

I just want to ask here if there's any workaround with the disconnect issues we're encountering when subscribing to realtime events in react native using expo and also having this INVALID_STATE_ERR.

ERROR Realtime got disconnected. Reconnect will be attempted in 1 seconds. Stream end encountered ERROR Error: INVALID_STATE_ERR, js engine: hermes

Here's how we implemented in subscribing for realtime events based off on your documentations:

useEffect(() => { let unsubscribe = null;

TypeScript
const setupRealtimeListeners = async () => {
  try {
    unsubscribe = client.subscribe(
      [
        databases.${secrets.appwriteConfig.databaseId}.collections.${secrets.appwriteConfig.messagesCollectionsId}.documents,
        databases.${secrets.appwriteConfig.databaseId}.collections.${secrets.appwriteConfig.chatsReadCollectionId}.documents,
      ],
      (response) => {
        if (response.payload?.$collectionId === secrets.appwriteConfig.messagesCollectionsId) {
          handleRealTimeMessagesEvents(response);
        } else if (response.payload?.$collectionId === secrets.appwriteConfig.chatsReadCollectionId) {
          handleRealTimeMessageReadEvents(response);
        }
      },
    );
  } catch (err) {
    console.error("Realtime not ready or subscription failed:", err);
  }
};

setupRealtimeListeners();

return () => {
  if (unsubscribe) unsubscribe();
  chatIdRef.current = null;
};

}, []);

TL;DR
User is experiencing real-time disconnects and an error message: INVALID_STATE_ERR. Another user is asking for help and a possible solution.
25 Jul, 2025, 03:05

hi same issue here, did u manage to solve it?

31 Jul, 2025, 15:27

Unfortunately still no 🙁

10 Oct, 2025, 21:27

<@706830938205847563> did you solve this if yes how ?

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more