rlamasb / Firebase.Xamarin

Light weight wrapper for Firebase Realtime Database REST API.
MIT License
149 stars 39 forks source link

Delay with Firebase.Xamarin.Database.Streaming? #22

Open Awesometimes opened 7 years ago

Awesometimes commented 7 years ago

Hi,

I've been scratching my head for the past several hours with regards to observing/subscribing to a child/key. I see the changes via the Firebase DB, but on the client, I've noticed a delay of upwards to 40 seconds when listening for changes, which doesn't seem very real time to me.

I'm not sure if it's this library or RX.Net that's causing the delay.

Here's what I got; pretty standard:

_currentUserObserver = firebase
  .Child(Keys.Users)
  .WithAuth(authToken)
  .AsObservable<Dictionary<string, object>>()
  .Where(f => !string.IsNullOrEmpty(f.Key))
  .Where(f => f.Key == CurrentUser.Key)
  .Subscribe(d => Debug.WriteLine("Observing"));

I've played around with some of the RX.Net LINQ statements, such as .Sample(TimeSpan.FromSeconds(1)) or .Throttle(timeSpan), but no luck. Reference: http://stackoverflow.com/questions/3211134/how-to-throttle-event-stream-using-rx

Any thoughts?

micdoug commented 7 years ago

I'm also experiencing this high delay problem. Did you discover a solution to this?

pbrownTexasDevices commented 7 years ago

Ive found that there isn't necessarily a delay, but my incoming streams are one change late. Nothing updates in real time, its as if a queue holds on to one change before receiving the next one.

ShiroYacha commented 7 years ago

@pbrownTexasDevices I have the same situation... did you find the issue? After testing with curl I don't have the one update later issue...

Edit: I have a bug on my side... The issue is the subscriptions exceptions are logged in debug mode and I didn't see it... My error was the data class does not have a default constructor... weird right... once I fixed that it works... no delay