Hi! 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;
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;
};
}, []);
@Cara Santos @Luis P. @Ian R.
Recommended threads
- Roles Enum Limitation in Kotlin SDK
The createMembership method in the Appwrite Kotlin SDK now requires List<io.appwrite.enums.Roles> instead of List<String>, but the predefined Roles enum only co...
- 1:1 relationship doesn’t sync after re-a...
Hi, I’m trying to use a two-way one-to-one relationship. It works fine when I create a record with the relationship set, and it also works when I unset it. But ...
- Upsert with setting permissions
Hi there, I am using self-hosted appwrite v1.7.4 and trying to use the bulk update stuff that was released with 1.7.x. Unfortunally I found that there is an ser...