Closed mcchin closed 1 month ago
This is a different unexpected behaviour but might share the same root cause with https://github.com/appwrite/sdk-for-web/issues/24
Yeah, that is actually expected behavior as of right now.
The realtime server is only aware of the session when the user connects. So once the user is connected and authenticated, the connection is assigned to a specific user - not session.
To prevent this, I can only think of re-establishing the connection after a session is /created/deleted.
This definitely require some more work and planning to fix.
@TorstenDittmann
Thanks for the feedback
To avoid non-authorized user receiving data from Websocket, currently I am thinking to refresh the page after user click logout. Do you have other recommendation?
I have also noticed if I have unsubscribed to a channel, although the callback is not fired but I will still be receiving data from Websocket
I have also noticed if I have unsubscribed to a channel, although the callback is not fired but I will still be receiving data from Websocket
Can you provide me the list of channels where that happens?
I have also noticed if I have unsubscribed to a channel, although the callback is not fired but I will still be receiving data from Websocket
Can you provide me the list of channels where that happens?
collections.COLLECTION_ID.documents
is what I am using currently
But looking at the current behaviour I suspect all channels will have the same issue where when you have unsubscribed a channel you will still be receiving data messages at Websocket
level. As I have also noticed when you have unsubscribed a channel nothing is sent back to server side, so I am speculating server side don't know client side has unsubscribed a channel
I have also noticed if I have unsubscribed to a channel, although the callback is not fired but I will still be receiving data from Websocket
Can you provide me the list of channels where that happens?
collections.COLLECTION_ID.documents
is what I am using currently But looking at the current behaviour I suspect all channels will have the same issue where when you have unsubscribed a channel you will still be receiving data messages atWebsocket
level. As I have also noticed when you have unsubscribed a channel nothing is sent back to server side, so I am speculating server side don't know client side has unsubscribed a channel
The logic should be, to only reconnect and therefore tell the Realtime Server the new list of channels, when you unsubscribe from a channel when there is no subscription attached to it anymore.
I'll check on my side what's happening π
@TorstenDittmann I think this has been fixed by https://github.com/appwrite/sdk-for-web/pull/93
π Reproduction steps
Config/Setup:
To reproduce:
Login as
User A
, e.g.sdk.account.createSession(User A email, User A password)
At a React page, using WebSDK to subscribe to a channel like so
Update any of the documents on the said collection from Appwrite Console, and I can noticed data is received, and channel/subscription callback is executed
User A
logout,unsubscribe()
is fired, and thenUser A
is logout like sosdk.account.deleteSession('current')
/sdk.account.deleteSession(session_id)
NOTE: Don't refresh browser page or close the browser tab, if you have refreshed browser page or close the browser tab you can't reproduce the issueUpdate any of the documents on the said collection from Appwrite Console, at the same browser tab where
sdk.account.deleteSession
is executed and I can noticed data is still being received As seen in image below where data still coming into Websocket , but channel/subscription callback is NOT executedπ Expected behavior
As described in reproduction steps above, I am expecting Websocket stop receiving data after session is removed after
sdk.account.deleteSession('current')
/sdk.account.deleteSession(session_id)
π Actual Behavior
After
sdk.account.deleteSession('current')
/sdk.account.deleteSession(session_id)
, Websocket still receiving dataπ² Appwrite version
Different version (specify in environment)
π» Operating system
Linux
𧱠Your Environment
π Have you spent some time to check if this issue has been raised before?
π’ Have you read the Code of Conduct?