firedart icon indicating copy to clipboard operation
firedart copied to clipboard

RPi stream close automatically after some time

Open kekko7072 opened this issue 3 years ago • 14 comments

I have an app running forepart plugin on a RPi with flutter-pi. I use firebaseCollection.document(docName!).stream to load the database value from firebase. I tried using wifi or network cable but I still have this issue, so is not linked to issue My code is

StreamBuilder<....>(
        stream: firebaseCollection.document(docName!).stream,
        builder: (context, snapshot) {
          if (snapshot.hasData) {
      ////
}
else {
            return Center(child: CircularProgressIndicator());
          }
        },
      ),

Any workaround to solve this issue with more code or implementation for firedart?

kekko7072 avatar Jun 11 '21 14:06 kekko7072

I am facing the same issue in native dart, streams stop responding after couple of hours without crashing or showing any errors.

This could be from the same reason of other issue that I am facing #43. As the creator of this package wrote

we learned that Firebase actually requires an updated token even after the stream is opened. Firedart currently doesn't do this,

I think this is why your stream is breaking after a while

Unfortunately doing that would require a major rewrite to the entire project, which I currently do not have the time to do. My advice to you would be to use a different package, or not use the real-time stream part of the package.

guyluz11 avatar Jun 11 '21 14:06 guyluz11

Tested again now with

yield* ref.stream.handleError((e) => {print('Handling Error Now')});

And

    collectionsStream!.onError((e) => {print('Error in real-time stream')});
    collectionsStream!.onDone(() => {print('Real-time stream is done')});

None of them showed any response when the stream stop responding.

I think that no matter what the cause of the problem, firedart package should throw us error when the stream stopped working. Maybe we can even try to handle this ourselves by restarting the stream manually or other workaround with our app.

@cachapa do you think that throw error could be more feasible?. Is there area in code that I should start looking from there?.

guyluz11 avatar Jun 11 '21 15:06 guyluz11

Tested again now with

yield* ref.stream.handleError((e) => {print('Handling Error Now')});

And

    collectionsStream!.onError((e) => {print('Error in real-time stream')});
    collectionsStream!.onDone(() => {print('Real-time stream is done')});

None of them showed any response when the stream stop responding.

I think that no matter what the cause of the problem, firedart package should throw us error when the stream stopped working. Maybe we can even try to handle this ourselves by restarting the stream manually or other workaround with our app.

@cachapa do you think that throw error could be more feasible?. Is there area in code that I should start looking from there?.

I agree with you. We could handle the error restarting the stream but how?

For example do you think rebuild the page could be an acceptable option? Or you you have a better option?

kekko7072 avatar Jun 11 '21 18:06 kekko7072

@guyluz11 You are working on an stable solution to this bug? In particular are you migrating firedart to use auth from firebase_auth_rest and this will solve the stream issue? Am I right? Fell free to keep me updated with news about. I am creating an app witch need to be stable for September, I am not very expert but I want to help if needed.

EDIT: i see in the issue you opened, this migration will hopefully solve the problem.

kekko7072 avatar Jun 13 '21 17:06 kekko7072

Yes @kekko7072 I am trying to migrate this package to use auth from firebase_auth_rest.

Unfortunately this on it own didn't solve this issue but it did throw exception. This is good news because in the meantime if exception is thrown than we can catch it and restart the stream ourselves out side of this package. As to how and what is the best way to implement that I will save to the future after my pull request will get accepted.

Maybe patch like this will be implemented inside the package until we will figure out how to solve it correctly, and for you this will just work as if everything is ok without changes.

guyluz11 avatar Jun 13 '21 23:06 guyluz11

@kekko7072 I went one step forward and created issue in dart-lang / http about the null safety crash in firebase_auth_rest https://github.com/dart-lang/http/issues/581 You can help by saying that this is effecting you too.

guyluz11 avatar Jun 16 '21 12:06 guyluz11

Sorry for the late response but I'm under university exams now until the 15th of July :( After that I will try.

kekko7072 avatar Jun 24 '21 09:06 kekko7072

Hey @guyluz11 I am back from university exams, any updates? Now I have a full month to work on!

kekko7072 avatar Jul 14 '21 19:07 kekko7072

My pull request is waiting for review.

guyluz11 avatar Jul 14 '21 20:07 guyluz11

@guyluz11 ok when its ready comment and i Will test It and then close the issue.

kekko7072 avatar Jul 16 '21 10:07 kekko7072

@guyluz11 any update?

kekko7072 avatar Mar 18 '22 14:03 kekko7072

@kekko7072 I am not the maintainer of this package so it is not on my hands.

Please keep updated in this

https://github.com/cachapa/firedart/pull/67

guyluz11 avatar Mar 18 '22 15:03 guyluz11

Don't close the issue, it is important to keep track.

guyluz11 avatar Mar 18 '22 16:03 guyluz11

Guys, sorry for my lack of availability for this. I've been ultra busy with my own startup which unfortunately doesn't use Firebase so I haven't had any time for this project.

I'm really not sure what to do here. On the one hand I'm not comfortable with blindly accepting PRs, on the other I feel bad about leaving the community hanging.

cachapa avatar Mar 18 '22 19:03 cachapa

Closed by #130

cachapa avatar Feb 22 '24 12:02 cachapa