Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃悰 Bug Report: Realtime got disconnected #8037

Open
2 tasks done
dj-fiorex opened this issue Apr 29, 2024 · 6 comments
Open
2 tasks done

馃悰 Bug Report: Realtime got disconnected #8037

dj-fiorex opened this issue Apr 29, 2024 · 6 comments
Assignees
Labels
api / realtime Fixes and upgrades for the Appwrite Realtime API. bug Something isn't working

Comments

@dj-fiorex
Copy link

dj-fiorex commented Apr 29, 2024

馃憻 Reproduction steps

When i use realtime to listen to database i get this error:

WebSocket connection to 'wss://cloud.appwrite.io/v1/realtime?project=<project>&channels%5B%5D=databases.6623e3aa881153ccd832.collections.orders.documents.662b7dbd6748895df4a6' failed: 
Realtime got disconnected. Reconnect will be attempted in 1 seconds. 

The same code was working till two days ago.
I'm connected to AppWrite Cloud with starter free plan.
The project is a simple vite + react project, the interesting parti is this:

FILE Test.tsx

import { useEffect } from 'react';
import { subscribeToOrder } from '../backend';

export const TestCmp = () => {
  useEffect(() => {
    const unsubOrder = subscribeToOrder('662b7dbd6748895df4a6', (order) => {
      console.log('order changed: ', order);
    });
    return () => {
      console.log('Unmounted Home');

      if (unsubOrder) {
        console.log('unsub');
        unsubOrder();
      }
    };
  }, []);

  return (
    <div>
      <h1>Test</h1>
    </div>
  );
};



FILE backend.ts

import { Client, Storage, Account, Databases, Models, ID, Permission, Role, Query } from 'appwrite';

export const client = new Client();

client.setEndpoint('https://cloud.appwrite.io/v1').setProject('<projectID>'); // Replace with your project ID

export const account = new Account(client);
export const db = new Databases(client);
export const storage = new Storage(client);

const databaseID = '<dbID>';
const bucketID = '<bucketID>';
const excelFileID = 'template-excel';
export { ID } from 'appwrite';

type OrderDocument = Order & Models.Document;
type OperatorDocument = Operator & Models.Document;
type TestDocument = Test & Models.Document;

export const subscribeToOrder = (orderId: string, callback: (order: Order) => void) => {
  return client.subscribe<OrderDocument>(
    `databases.${databaseID}.collections.orders.documents.${orderId}`,
    (response) => {
      // Callback will be executed on changes for documents A and all files.
      console.log('collections.orders.documents', response);
      callback({ ...response.payload, id: response.payload.$id });
    }
  );
};

馃憤 Expected behavior

Connect and listen to realtime events from the server.

馃憥 Actual Behavior

WebSocket connection to 'wss://cloud.appwrite.io/v1/realtime?project=<project>&channels%5B%5D=databases.6623e3aa881153ccd832.collections.orders.documents.662b7dbd6748895df4a6' failed: 
Realtime got disconnected. Reconnect will be attempted in 1 seconds. 

馃幉 Appwrite version

Appwrite Cloud

馃捇 Operating system

Linux

馃П Your Environment

"appwrite": "^13.0.2",
"react": "^18.2.0",

馃憖 Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

One issue that i found is this #1640 but it talks about a self hosted instance of AppWrite, so this is not my use case

馃彚 Have you read the Code of Conduct?

@dj-fiorex dj-fiorex added the bug Something isn't working label Apr 29, 2024
@dj-fiorex dj-fiorex changed the title 馃悰 Bug Report: 馃悰 Bug Report: Realtime got disconnected using Appwrite Cloud Apr 29, 2024
@ItzNotABug
Copy link
Contributor

If this was working around 2 days ago, its possible this is due to Cloud's update to 1.5.5.
Can you try using the latest sdk version for web 14.0.1?

@stnguyen90 stnguyen90 added the api / realtime Fixes and upgrades for the Appwrite Realtime API. label Apr 29, 2024
@stnguyen90
Copy link
Contributor

@dj-fiorex, thanks for raising this issue! 馃檹馃徏 I have seen some instability with realtime lately. I don't think it's a Cloud-only problem, but I think it's more apparent on Cloud due to the load. I think it's due to the concurrent connections causing conflicts/problems and improving that is going to take significant changes 馃槙

@stnguyen90 stnguyen90 self-assigned this Apr 29, 2024
@cwwngwphqn
Copy link

@stnguyen90 Do you have any news regarding that by chance? By now, the realtime connections always fail in my project hosted on cloud.

@stnguyen90 stnguyen90 changed the title 馃悰 Bug Report: Realtime got disconnected using Appwrite Cloud 馃悰 Bug Report: Realtime got disconnected May 7, 2024
@stnguyen90
Copy link
Contributor

@cwwngwphqn, we're still working on it.

@cwwngwphqn
Copy link

It is working for me again 馃檹

@cwwngwphqn
Copy link

Unfortunately now not anymore 馃槩

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api / realtime Fixes and upgrades for the Appwrite Realtime API. bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants