Back

client.subscribe error: 1003, Message type is not valid.

  • 0
  • Self Hosted
  • React Native
  • Realtime
Finn24.09
2 Jan, 2025, 10:42

Hello everyone,

When I use client.subscribe within my React.js + vite webapp with the following lines of code: Code sniped:

TypeScript
[AppwriteConfig.tsx]
import { Client, Account, Databases } from "appwrite";

export const client = new Client()
  .setEndpoint("https://MYENDPOINT/v1")
  .setProject("MYPROJECTID");

export const dbID = "MYDBID";
export const collectionID = "MYCOLLECTIONID"

[App.tsx]
import {
  client,
  dbID,
  collectionID,
} from "./AppwriteConfig";

useEffect(() => {
const unsubscribe = client.subscribe(
      `databases.${dbID}.collections.${collectionID}.documents`,
      (response: any) => {
        if (
          response.events.includes(
            "databases.*.collections.*.documents.*.update"
          )
        ) {
          // Log when a new file is uploaded
          console.log(response.payload.item);
        }
      }
    );
return () => {
  unsubscribe();
};
}, []);

It should subscribe to the event for updates and don't show any errors.

Unfortunately, It acutely constantly sends an error inside the browser, but the subscription works anyways. code: 1003, message: 'Message type is not valid.' The Realtime Container logs don't show any errors.

TypeScript
Server started successfully
Connection open (user: 1)

I tested this behavior on my cloud server with side to side VPN to my home network, as well as on a completely new and clean vm on my local machine without any customization of the appwrite container stack.

Many thanks and best regards.

TL;DR
Issue: When using client.subscribe in a React.js + Vite web app, error code 1003 "Message type is not valid" is displayed in the browser, despite the subscription working. Solution: The error is shown but does not impact functionality. The subscription still works correctly. Logs in the Realtime Container don't indicate any issues. Tested behavior on a cloud server with a VPN to a home network and on a clean local VM without customization.
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