Open merabtenei opened 1 year ago
@lohanidamodar, would you be able to check on this?
@lohanidamodar, would you be able to check on this?
Just found something: I cloned the flutter Sdk and managed to detect when the Websocket gets closed : In the file realtime_mixin.dart
_websok?.stream.listen(
(response) {
...
},
// Added these callbacks
onError: (err, st) =>
debugPrint('realtime_mixin:onError: ${err.toString()}'),
onDone: () => debugPrint('realtime_mixin:onDone'),
);
I added onError and onDone callback and now I can see realtime_mixin:onDone on the console, I think from here we need to do something to receive the closing event. As of now onDone or onError of the Stream provided by the subscribe method are not triggered. It's the first time I take a look inside the Sdk code, so I'm not sure if that's all what it takes to fix it.
@merabtenei Thanks a lot on identifying the issue, I'll look into it and come back to you.
I have an addition to this topic. Executing a realtime subscription in a background or foreground service is terminated a few seconds after a screen lock or app going to background. Using this package could help : https://pub.dev/documentation/websocket_manager/latest/
This plugin was created due to our necessity to maintain a WebSocket connection active in background while Flutter's WebSocket from cookbook doesn't keep alive while screen is locked or the application was in background.
Is there any update regarding this one ? Is there any safe way to detect if the subscription connection was lost due to the device loosing access to internet ?
@merabtenei we cannot use websocket manager as it supports only android and iOS. I'm looking it getting a message back so that we will know when the connection was closed.
@merabtenei can you check if you get back the message on subscription.stream.onDone
when websocket closes with this changes?
https://github.com/appwrite/sdk-for-flutter/tree/fix-websocket-issue
@merabtenei can you check if you get back the message on
subscription.stream.onDone
when websocket closes with this changes? https://github.com/appwrite/sdk-for-flutter/tree/fix-websocket-issue
I confirm that onDone callback is being correctly triggered now. Good job.
π Reproduction steps
I'm using Flutter and below is a very simple app that will reproduce this behavior.
π Expected behavior
One of two scenarios :
π Actual Behavior
π² Appwrite version
Version 1.1.x
π» Operating system
Linux
𧱠Your Environment
No response
π Have you spent some time to check if this issue has been raised before?
π’ Have you read the Code of Conduct?