How to handle client is offline problem in javscript? [duplicate] - firebase

This question already has answers here:
Could not reach Cloud Firestore backend - React native Firebase v9
(2 answers)
Closed 7 months ago.
When the internet connection is good my website works fine but when the internet connection goes down firebase return an error called "Client is Offline".
Also sometimes I get problems like -->
[2022-08-04T10:42:54.098Z] #firebase/firestore: Firestore (9.6.7): Could not reach Cloud Firestore backend. Backend didn't respond within 10 seconds.
This typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend.
Please help. Thank you in advance.

We were experiencing this issue with slower (although functioning) internet connections. The only thing that fixed this was adding experimentalForceLongPolling: true to our config. You can read about this here and here. We struggled with this for weeks so hope this helps.

Related

how to detect the device connectivity state while using firebase? [duplicate]

This question already has answers here:
Check whether there is an Internet connection available on Flutter app
(27 answers)
Closed 2 years ago.
I'm using flutter with firebase, how can I know if my device is connected to the internet or not when I wanna make a query to firestore? if my device is offline what will firestore return ?, I must detect the device connectivity situation, so I can emit a certain state in my app.
The Firestore SDK doesn't provide any way to know if the app is offline. The SDK was designed to work while offline. So, if you perform a query while offline, you will either get cached results, or the query will silently retry in the background.
If you want to test for connectivity, you will need try another method to do that. Or, you could use the Firestore REST API (not the Flutter SDK) and detect if the query failed due to network problems.

What prevents clients from taking advantage of your Firebase apiKey in the client code? [duplicate]

This question already has answers here:
Is it safe to expose Firebase apiKey to the public?
(10 answers)
Should I hide firebase api keys into backend? Not due to data security but project cloning issue
(2 answers)
Closed 2 years ago.
I have been messing around with Firebase in a web app and realized there's something I don't understand.
In order for the JS code to send data to the Firebase servers, your apiKey has to be in the JS. But then that means your API key is public, and anyone using your website can inspect the code and just send arbitrary commands to Firebase on your behalf from the dev tools, or from any other site now that they have the API key.
I know I must be missing something, since this would make Firebase not useful. What is it I'm missing? What prevents users from sending arbitrary commands to Firebase with your ApiKey?

Is it possible to run graphql subscriptions on firebase?

I want to use GraphQL subscription with Firebase cloud functions.
In my previous question I described that when I deployed my code to Firebase it threw me "Could not connect to websocket endpoint." and I couldn't even connect to it manually,but when running locally everything works like a charm.
After that I went to see if it is possible to run subscriptions with Firebase,but didn't find anything,only for queries and mutations(it works for me too).
The only post I have found is this:
https://www.reddit.com/r/graphql/comments/aijebt/graphql_on_firebase/
where someone wrote this :
"No support for GraphQL subscriptions. GraphQL subscriptions rely on a
persistent web socket connection. Since functions shutdown during
inactivity, persistent web socket connections are impossible to
support."
However I don't want to give up here,because it was 6 months ago,and he said it he tried it while it was beta,so I'm hoping it have the support now.
So my question is:
Is it possible to run subscriptions on Firebase?
If not what are your
advise to do real-time stuff on back-end with Firebase?
Thanks!
Accordingly to some posts firebase-functions has a maximum lifetime of 9 minutes,so the subscriptions won't work.

Firebase - Offline behaviour for Unity

I recently started working on my game using Firebase and considering what Firebase offers is pretty much all I need, at one place. But now i'm facing few limitations/implementation issues so any help would be appreciated.
I'm developing a semi-online game which will allow users to play as long as no network is available and sync with Firebase soon as it gets connected. For very first launch connection is mandatory as i've to pull configuration data from Firebase and later user can play with offline saved state which will be pushed later whenever connected.
I'm quite noob to Firebase so pardon me if I misunderstood any implementation. I looked over different answers and mostly were in respect to native Android/iOS, not for Unity. So either I wasn't able to find my answer or it was asked years ago but still not answered. Thanks!
Disk persistence for the Realtime Database is now available since version 5.4.0 of the Firebase SDK for Unity. See the documentation for FirebaseDatabase. SetPersistenceEnabled() and the release notes for that version.
Old question but still hard to find a correct answer.
Firebase documentation is definitively ambiguous : on this page :
https://firebase.google.com/docs/database/unity/start
First lines :
"The Firebase Realtime Database stores and synchronizes data with our NoSQL cloud database. Data is synced across all clients in realtime, and remains available when your app goes offline."
Unity Firebase does not support real offline capabilities.
It will work only if your game starts with a network ON, and while playing, if the player has network OFF, it will go on correctly as long as you have the network ON before stopping the game ! so it can synchronize.. otherwise all changes are lost !
Here is a answer coming from the firebase support on this problem :
Currently, Unity doesn't support offline capability. Apologies about this. This is indeed something we're looking into, however, I cannot guarantee that this will be available anytime soon. We'll keep your feedback in consideration moving forward.
The documentation is explaining that your app will continue to save your data while offline. When data is written, it's written to this local version first and synchronizes that data to the server once connectivity is reestablished. Check here for more details. For additional context, Firebase's network resilience will work on Unity. So as long as the app stays active, Firebase will continue functioning if the network connection drops. In that case it serves any reads from its cache and keeps a queue of pending writes. But currently there is no support for disk persistence, which would allow the cache and queue to survive during app restarts.
I activated
FirebaseDatabase.DefaultInstance.SetPersistenceEnabled(true);
during initialization of my game.
It works fine in iOS but it does not work in Android.

Firebase Notification and Cloud Messaging [duplicate]

This question already has answers here:
Firebase FCM Usage Limits [closed]
(3 answers)
Closed 6 years ago.
I have a question about Firebase. I've developed an app with GCM implementation service and I'll be updating it to Firebase. What I would like to know is if there is any limit for sending notifications to my client?
What is the limit number of notifications in a day and for clients in a day? Google says the service is free, but there isn't any documentation of license to use it. Does anyone know about it? Thanks in advance.
There is no limit to the number of notifications you can push with fire base daily, or at least I haven't had any issues with it and Google sure didn't mention push notifications as a limited feature

Resources