0

I recently moved our web application from Google Appengine (python 2.7) to Nodejs/Firebase/Firestore.

When hosting on Google Appengine users could access the database (NDB) regardless if they were behind a corporate proxy or not.

Now, since switching to Firestore, users behind a corporate proxy cannot access their data that is stored in Firestore.

The answer here indicates that the user has to make some adjustments to their firewall configuration for applications using Firestore to work. So, at the very least, I'd like to indicate to the user that the application is not working because they need to make adjustments to their firewall.

How can I detect if the user is having trouble accessing the Firestore because of a proxy? Are any of the FirestoreErrorCodes triggered in this case?

1 Answers1

0

This question has been answered before here and here. As mentioned it, there's not built in feature that tells that you're working offline and you will have to rely on external methods to test it, as suggested there is one property named metadata.hasPendingWrites that can help you to determine whether the document has local changes that haven't been written to the backend yet and you can use this to determine if Firestore has been able to reach the server.

Emmanuel
  • 1,436
  • 1
  • 11
  • 17
  • The proxy issue is not necessarily the same as the user being offline. When a user is behind a proxy s/he can still retrieve and render data delivered from e.g. firebase cloud functions. I can have the cloud function interact with firestore and deliver data to the user but the direct interaction from the client to firestore is what is not working. I understand the challenges and will probably work around them with e.g. cloud functions. – Sólveig Kjartansdóttir Aug 31 '20 at 18:24
  • Is the user able to write the document? If not, even if it's not the same issue the solution could be similar as you could be able to determine that you can't reach the server to write. – Emmanuel Aug 31 '20 at 18:33
  • Good point. In my case the user needs to read the data. – Sólveig Kjartansdóttir Aug 31 '20 at 20:29
  • Could you be more specific about the errors that you're getting while trying to read from behind the proxy? Are you using the admin or client SDK for nodejs? Can you tell more details about your specific implementation so maybe I can suggest a possible workaround? – Emmanuel Sep 01 '20 at 00:01
  • I appreciate your willingness to help Emmanuel. The workaround will depend on our implementation in each case. We can figure out how to handle that. Thanks for giving this your attention. – Sólveig Kjartansdóttir Sep 01 '20 at 18:46
  • Sure, anytime. You can probably want to look at the property [fromCache](https://firebase.google.com/docs/firestore/manage-data/enable-offline#listen_to_offline_data) to notice if you're getting offline information on the reads – Emmanuel Sep 01 '20 at 22:52