cachapa / firedart

A dart-native implementation of the Firebase Auth and Firestore SDKs
https://pub.dev/packages/firedart
Apache License 2.0
174 stars 62 forks source link

gRPC stream error when Token expires - Missing or invalid authentication. #45

Closed meteorza closed 4 years ago

meteorza commented 4 years ago

Hi

Using latest 0.8.3 in Dart VM console app. (same issue with the previous version)

The app is listening to a collection stream. Works without any problems when the app is started, but after 1 hour (which is probably when the token expires), the following "listen onError" appears:

gRPC Error (code: 16, codeName: UNAUTHENTICATED, message: Missing or invalid authentication., details: [])

As a workaround, I have tried:

The rest of the once-off document updates (update and delete) still work without any problem after 1 hour, just the stream that is broken and which I can not seem to recover/reload.

I am not sure what is causing the error, but I am happy to just restart the stream. Is there a specific way to reinitialize the stream in firedart which I am not aware of?

I would appreciate any feedback or suggestions.

cachapa commented 4 years ago

It seems the protobuff models have their own token renewal meachanism which firedart isn't currently using. Unfortunately using those would imply a huge redesign on the entire library since token handling is central to the entire setup.

I'm don't currently have the time to do it so it might make more sense to use another library if you're having trouble with firedart.

meteorza commented 4 years ago

I understand, besides the streaming problem, firedart is just fine for my requirement.

As a workaround, I run the stream subscription in its own isolate. Every 59 minutes I do the following:

Takes about 1 second. After restarting the stream, I get the missed collection documents updates anyway.

Bit of a hack, but it works for me :-)