-
Notifications
You must be signed in to change notification settings - Fork 928
Firestore Auth does not work in Cordova #2586
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi @rommelpe |
@Pitouli Can you share debug logs? You can enable them via In general, most of the Cordova related networking issues we have observed were caused by third-party plugins or ServiceWorkers. If your networking issues persists, we may need a reproduction to see if there are any dependencies that interfere with the WebChannel stack. |
@schmidt-sebastian : https://gist.github.com/Pitouli/203e68dcc588876174b0630b1c3707a9 I try to create a small app |
A project I created for debugging another issue (#2581) can be used to reproduce the bug. The github : https://github.com/Pitouli/debug-ios-vuexfire When you open it, you have a list of "dates". If you click on "add message", it publish a new "date" to the collection, which should appears on all the open apps. As you can see, it works well on the web (except the bug described in the issue #2581 ). |
@Pitouli Thank for for the repro. I will give this a spin tomorrow (Tuesday) Pacific time. |
I am able to reproduce this using your app in the iOS Simulator. |
@Pitouli I looked at this more. What I actually see is a behavior that is similar to what users have described that are sitting behind corporate proxies. Some proxies only seem to forward responses once the connection is closed explicitly by the backend. Due to the way WebChannel works (which is our network stack for the JavaScript-based client) this introduces a latency of 60s per request. This is well above the 10s threshold at which we consider the client offline. The WebChannel team is currently trying to figure out if they can detect these situations automatically. Until that is the case, you can opt into a fallback that addresses this issue. If you set experimental-force-long-polling to
Thanks for the repro. This will likely help many other users. |
Thanks for your help! My iPhone is a corporate one, but I do not think it has a special proxy. And for sure, my iOS Simulator has no corporate configuration, and it runs on a personal mac mini which is connected on a personal internet connexion (and I have not installed any firewall/antivirus), so I do not understand why there would be proxy issues. Nevertheless, I tried to add the setting, and it effectively solved the issue on my "repro app", but sadly it hasn't solved my issue on my real app which uses Firebase Auth. Now, I receive another error when I try to Full log: https://gist.github.com/Pitouli/868f9c2158889f68cb7b20970b6603a3 Note that even with the setting experimentalForceLongPolling, the app still works as expected when it is not in Cordova (no "permission-denied" error). I'll try to update my repro app to add an auth system, so I can request stuff controlled by firestore rules, and see if the issue can be reproduced. Thanks Note: I cannot test on my iPhone until next week, so I only tested on the iOS Simulator |
I meant to say that Cordova exhibits the same network latency that we have seen on some corporate networks. For this, Cordova does not seem to have to be behind a Proxy.
It looks like we need to add a special exception for Cordova to also omit some of our header values in our HTTP requests. You can see the code and the rationale for this: firebase-js-sdk/packages/firestore/src/platform_browser/webchannel_connection.ts Line 278 in dac1757
|
Thank you for the details! |
@thebrianchen will be in contact should we need additional information. |
@Pitouli I am currently trying to reproduce the issue, and I am having trouble getting past the login screen. I've cloned your repo, and built the app with the command What are the additional steps needed to get the app running? Also, where are the logs outputted to by default? Thanks! |
@thebrianchen : I updated the app on the master branch to help you reproduce the bug I have on my "real" app. Start by running the app as a web app: When the app opens in your browser, you should have a email/pwd form with a login and a sign-up buttons, and a "Google Connect" button below. Once you're logged in, you will see a home page. Test in multiple browsers with multiple account: everything behaves as expected. Now, compile the app for cordova and run it: In cordova, everything works as described above, EXCEPT the "authenticated list": when you "Add User Message" in this list, you have an error in the console: Three interesting things to notice:
Last but not least, these are my current rules (I commented below the "permissive rules" with which the auth list works correctly even with cordova):
|
Currently, I only tested the cordova app on iOS. When you run a Cordova app on iOS (whether it is on a real device or on the simulator), you can access the console by using Safari on the mac connected to the iPhone / running the simulator. Open Safari, choose "Development" in the menu bar (after having enabled development mode in the preferences of Safari) and you should find your (virtual) device in the list. And you should find the running app ready to be debugged. |
Btw, I'm looking at my Firestore console and I observe that in one week there was 23k read of only 37 documents! 😢 Is it related to some tests you have run (in this case everything is fine; it's made for that)? |
It's hard to pinpoint exactly one reason for why your app has had so many reads just by looking at the table -- here are some common sources of usages:
Lastly, you currently have your security rules set to public, so anyone can clone and access your database. If you tighten your security rules and continue to see high reads/writes, you should examine your app's Firestore API calls. |
I do not know how to test your custom version 😅 I downloaded the archive, and I was hoping to replace the EDIT : I found the right folder, sorry! |
Yes! It corrects the issue on my real app, at least with the simulator! I will test tomorrow (I need physical access to my computer) on my real device to be certain, but I am very confident it will work perfectly! 😃 Thanks a lot for your help, I'll keep you updated tomorrow about the success of the operation |
I have packaged my PWA as a Cordova application (everything is "out of the box" with Framework7)
The Auth is working as planned ; login/password is working without any modification, idem for anonymous auth. My Google identification is not working, but I know why (https://firebase.google.com/docs/auth/web/cordova -> need an Apple dev account).
My issue is that once connected, the Firestore functionalities seem unable to reach the backend. So everything works fine, but in offline mode. And I receive in the console the following message :
Firestore (7.7.0): Could not reach Cloud Firestore backend. Backend didn't respond within 10 seconds...
Since authentication is successful, I am certain that there is no real network issue.
To be honest, I do not know if it is a bug, or if I should use the iOS SDK.
So before I try to rebuild a testable project I can share with you, can you please confirm that Firestore JS should be compatible with Cordova app?
Thanks
The text was updated successfully, but these errors were encountered: