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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Bug Report: Realtime got disconnected #8037

Closed
2 tasks done
dj-fiorex opened this issue Apr 29, 2024 · 11 comments
Closed
2 tasks done

🐛 Bug Report: Realtime got disconnected #8037

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

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:https://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:https://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 😢

@dj-fiorex
Copy link
Author

I can confirm that this is not working as intended. guys i have 2 projects in production using AppWrite websocket connection and they aren't working. Is there a workaround? the problem is visible also on self-hosted instance?

@stnguyen90
Copy link
Contributor

@dj-fiorex what exactly is happening now?

@stnguyen90 stnguyen90 added the question Further information is requested label Jun 7, 2024
@dj-fiorex
Copy link
Author

Same thing of the first post,
Realtime got disconnected

Is there a way to know in my code that websocket disconnected? So I could reload the page?

Now I'm trying to self-host Appwrite to check if it will do the same thing or is the cloud instance the problem

Copy link

This issue has been labeled as a 'question', indicating that it requires additional information from the requestor. It has been inactive for 7 days. If no further activity occurs, this issue will be closed in 14 days.

@github-actions github-actions bot added the stale label Jun 16, 2024
@dj-fiorex
Copy link
Author

Guys i can confirm that with a self-hosted instance of AppWrite Realtime works like a charm!

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 question Further information is requested stale
Projects
Status: Done
Development

No branches or pull requests

4 participants