Coder Social home page Coder Social logo

Auth - Cordova - signInWithRedirect - A network error (such as timeout, interrupted connection or unreachable host) has occurred. about firebase-js-sdk HOT 12 CLOSED

firebase avatar firebase commented on July 30, 2024
Auth - Cordova - signInWithRedirect - A network error (such as timeout, interrupted connection or unreachable host) has occurred.

from firebase-js-sdk.

Comments (12)

google-oss-bot avatar google-oss-bot commented on July 30, 2024

Hmmm this issue does not seem to follow the issue template. Make sure you provide all the required information.

from firebase-js-sdk.

bojeil-google avatar bojeil-google commented on July 30, 2024

There are many reasons why network errors could occur.

Please provide details on your issue. The first thing you need to do is report network logs. Check the network call that is failing and please report it with full details.

I doubt this happens because of the browser tab plugin. It is hard to speculate on the exact reason with no data available.

Are other calls failing at the same rate? Can you check signInWithEmailAndPassword? This would help clarify if this is related to a network request to the Firebase Auth backend or something else client related.

Underneath, we also check navigator.onLine to check the status of the connection. Can you confirm this returns true when the connection fails?

from firebase-js-sdk.

washowasho avatar washowasho commented on July 30, 2024

What specific network logging will be helpful?

My initial post stated that signInWithEmailAndPassword works fine and still does consistently,, so I do not suspect it's a drop in connectivity.

I'm running the sample code provided by Google documentation. It's falling into the catch for getRedirectResult.

firebase.auth().signInWithRedirect(provider).then(function() {
  firebase.auth().getRedirectResult().then(function(result) {
    // This gives you a Google Access Token.
    // You can use it to access the Google API.
    var token = result.credential.accessToken;
    // The signed-in user info.
    var user = result.user;
    // ...
  }).catch(function(error) {
    // Handle Errors here.
    var errorCode = error.code;
    var errorMessage = error.message;
  });
});

Step 1 - signInWithRedirect function opens up a browser tab
Step 2 - Credentials are entered into provider's login screen within the browser tab
Step 3 - Browser tab closes, a small loader square shows up in the middle of the page
Step 4 - Error occurs (again, 90% of the time) in getRedirectResult, which is called when the browser tab closes.

Some additional data points:

  • This does not happen in browser mode, only Cordova (I only tested on Android so far)
  • I switched between cellular and WiFi, and still received the error.
  • I suspect there may be some similarities with #20

from firebase-js-sdk.

washowasho avatar washowasho commented on July 30, 2024

More info on XHR activity:

Called When Error:

  • verifyAssertion?key= (contains JSON response)

Called When Success:

  • verifyAssertion?key= (contains JSON response)
  • getAccountInfo?key= (contains JSON response)

from firebase-js-sdk.

washowasho avatar washowasho commented on July 30, 2024

Ok, just an update. @bojeil-google, I confirmed that my Cordova device was switching between offline and online when I checked 'navigator.onLine'. That would explain why Firebase worked sometimes and not other times. I was wondering why, so I plugged in the 'cordova-plugin-network-information' to determine if more information about my device's connection status. Then it was fixed... works every time. I'm looking now to see if the 'cordova-plugin-network-information' is a more accurate wrapper to 'navigator.onLine'. If so, Firebase Auth may be getting better information and not failing. Stay tuned.

from firebase-js-sdk.

bojeil-google avatar bojeil-google commented on July 30, 2024

Sounds promising. I suspected there may be issues with navigator.onLine in such environments when I heard recurring reports on network errors in Cordova apps. I just haven't been able to reproduce them to confirm this.

from firebase-js-sdk.

washowasho avatar washowasho commented on July 30, 2024

Including the cordova-plugin-network-information corrected this issue for me. I confirmed that the 'navigator.onLine' was occasionally 'false', which I believe was causing Firebase to think there was an issue. Once I added the cordova-plugin-network-information to my project, the problem went away. I didn't dig deep into why, but I suspect this plugin has a better wrapper around the navigator which may be giving Firebase better information. I did confirm this problem came back after removing the plugin, but re-applying it fixes it. I will update this if I dig deeper. I hope this helps.

from firebase-js-sdk.

washowasho avatar washowasho commented on July 30, 2024

Looks like this may have been solved in the latest release of Firebase 4.2.0. I'll be verifying when I get a chance.

"Refactored to not use navigator.onLine for offline detection in Cordova environments."

https://firebase.google.com/support/release-notes/js#4.2.0

from firebase-js-sdk.

mohshraim avatar mohshraim commented on July 30, 2024

face the same problem on WKWebView
anyone find the correct solution?

from firebase-js-sdk.

wahengchang avatar wahengchang commented on July 30, 2024

did you guys find out what was happened ?

from firebase-js-sdk.

redaelkhayat avatar redaelkhayat commented on July 30, 2024

@mohshraim @wahengchang
in you html file, try to change the Content-Security-Policy default-src 'self' to default-src *

P.S. hope you didn't give up on you projects because of this problem

from firebase-js-sdk.

mohshraim avatar mohshraim commented on July 30, 2024

@redaelkhayat
Thanks for suggestion, my case was somehow on different environment. but was giving the same error.
this full case 582
that was a bug on google backend. and they solve it

from firebase-js-sdk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.