-
-
Notifications
You must be signed in to change notification settings - Fork 200
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
Solving the realtime issues #1012
Comments
Today I checked if the _onClose()-method of the RealtimeChannel gets called and therefore the channel gets removed from the channels List. It does by receiving an event This happens after a couple minutes ( with token expiry time of 30 sec). |
I wanted to take a look at the realtime issues in the next weeks as well. That event is not listed here, but I found no usage of the event on the client as well, so it's probably sent from the server, yes. Was the application in background or foreground? An interesting event to keep an eye on are sent and received heardbeats. |
The application is open in "Full Screen" on macOS but the focus was on my IDE. So the output of the AppLifecycleListener was
Both, but I'm going to switch to testing it with just one from now on.
|
I actually couldn't reproduce this problem when I only had one realtime channel. When I switched back to accessing two (using the stream method), then the problem occurred again. Maybe #231 isn't working correctly? EDIT: the channels List being empty after some time also happens when only using only 1 stream. (using the stream method in a Flutter StreamBuilder) |
This comment was marked as duplicate.
This comment was marked as duplicate.
Leaving some thoughts for discussion: When subscribing to a realtime channel you can pass a callback function to the subscribe method like this:
Would it be possible to add an optional callback function to the Another approach could be exposing the channel name (topic) from the |
In my case, I noticed that when the app is minimized or out of focus for an extended time, the connection to the server often drops silently. Like you, there are no obvious exceptions or errors that would indicate a failure, which makes troubleshooting tricky. I’ve also been investigating whether the access token refresh could be a factor here, especially if the app is unable to properly reauthenticate when the token expires. I’ve also thought that a lack of heartbeat signals could be causing the server to close connections prematurely. From my research so far, a few things stand out:
|
@pseacrest Could you go into more detail on how exactly you did it? But let's see if the PR @Vinzent03 did fixes the issues. Maybe he can leave a comment on when the work will be finished. |
With #1019 being merged now, these issues should be solved now. You can try them by upgrading |
I would like to address the existing issues with realtime (e.g. #705, #579), particularly the problem where streams suddenly stop receiving data. I'm willing to spend some time investigating the source code and will report back if I find anything noteworthy. Since I'm not yet familiar with the repository, I would like to keep this issue as an open discussion. This will allow us to collaborate, so I can seek help if I encounter difficulties or if you believe my research is heading in the wrong direction.
If you have any additional information or thoughts on why this problem might exist, please leave a comment. Perhaps we can finally find a solution to these issues together as a community.
I'm using this repo for my local testing:
https://github.com/maxfornacon/supabase_test
I'm using latest supabase_flutter (2.6.0) and Flutter 3.24.0.
I'm running this test project on macOS as a desktop application.
The main problems I'm having with realtime in my projects for some time now is:
When the application is running for a longer period of time (e.g. desktop applications that are opened (might be in background) the whole day and don't get killed by the system) streams stop receiving new data after some time. There are no errors or exceptions thrown and the only solution I've found is to encourage the users to restart the application from time to time.
The current state of my research is that there might be a problem related to the accessToken refresh.
I've set the access token expiry time in supabase dashboard to a small value (30 seconds) and added a breakpoint in this method (realtime_client.dart):
This gets called every time the accessToken is refreshed and should update existing channels with the new token (that's my understanding).
I watched the
channels
List which contains 3 entries in the beginning for my test project. After some token refreshes this list contains < 3 entries and eventually 0 in the end. This is also when I noticed that the streams don't receive new data anymore.I don't know yet why the channels get removed from this list but It feels not intended.
That's my current status. I'm curious about your thoughts on this.
The text was updated successfully, but these errors were encountered: