Skip to content

com.google.firebase.FirebaseNetworkException: A network error (such as timeout, interrupted connection or unreachable host) #1985

Open

Description

@bolds07

[READ] Step 1: Are you in the right place? YES

[REQUIRED] Step 2: Describe your environment

  • Android Studio version: 3.6.3_
  • Firebase Component: Auth (Database, Firestore, Storage, Functions, etc)
  • Component version: 19.4.0

[REQUIRED] Step 3: Describe the problem

Steps to reproduce:

My app is production with over 500k downloads on google play and some user (i dont know exactly why) have this error when logging in...

com.google.firebase.FirebaseNetworkException: A network error (such as timeout, interrupted connection or unreachable host)
       at com.tomatedigital.giveawaymaster.task.LoginTask.lambda$firebaseAuth$1(LoginTask.java:249)
       at com.tomatedigital.giveawaymaster.task.-$$Lambda$LoginTask$p6eSSF8vZ2BATwhlFttcJl8qT-w.onComplete(-.java)
       at com.google.android.gms.tasks.zzi.run(zzi.java:4)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
       at java.lang.Thread.run(Thread.java:818)

there is no an easy connection between these users, different android versions, different phone models.... i found this old issue: #384 but seems that someone in firebase team just trew it under the carpet instead of solving it (very common here)

the error is happening in real devices in production,
Some users with problem come to support and ive asked to reinstall the app but they keep error... also it is not a INTERNET CONNECTION problem because people are talking to me in an online chat and having the problem in the same time

crashlytics show it is happening in 1% of sessions... but it is always same users

Relevant Code:

FirebaseAuth.getInstance().signInWithCustomToken(token).addOnCompleteListener(AsyncTask.THREAD_POOL_EXECUTOR, task -> {
                if (task.isSuccessful()) {
                    FirebaseCrashlytics.getInstance().log("new firebase token successfully authenticated");
                } else {
                    App.shouldNeverHappen(new RuntimeException(task.getException().getMessage() + " data: " + sb.toString()));
                    this.exception = task.getException();
                }

});

//token is generated in my Firebase cloud functions as
auth.createCustomToken(uid).then(function(customToken) {
		res.status(200).send(customToken);
	}).catch(function(error) {
		console.error("Error creating custom token:" + JSON.stringify(error));
		res.status(200).json({
			e: error
		});
	});

Activity

  1. google-oss-bot commented on Sep 16, 2020

    @google-oss-bot
    Collaborator

    I found a few problems with this issue:

    • I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
    • This issue does not seem to follow the issue template. Make sure you provide all the required information.
  2. bolds07 commented on Sep 18, 2020

    @bolds07
    Author

    3 days still NO answer... soon someone will come and say "this issue is closed due inactivity"

  3. malcolmdeck commented on Sep 21, 2020

    @malcolmdeck
    Contributor

    Hey bolds07,

    We check issues about once a week - the team is small. I appreciate your patience.

    As for the issue at hand, we don't have enough information to be able to triage this. Network errors like the one with the stack trace that you've posted are due to issues that happen at layers beneath the SDK - we called an API to make a network request and it failed. The fact that you say that this happens for the same users rather than randomly is interesting - it suggests that perhaps it is something specific to either the state or the hardware of their devices, but given that they have a variety of Android device models and OS levels, there's not a clear pattern that puts me in a position to investigate further.

    The good news is that I can say that your code looks like it should execute properly - there are no errors in how you've written the client-side or Cloud Function code.

    With the above being said, please do let us know if you find any more information that actually puts us in a position to be able to investigate further (for example, a project setup that results in the ability to reproduce this error repeatably).

    Thanks,
    ~Malcolm

  4. bolds07 commented on Sep 21, 2020

    @bolds07
    Author

    Unhappily this is error occurs in a high number of sessions around 1% which for my app is around 200users daily.

    i've many forums talking about google play services state and relating to this but nothing conclusive.

    if the engineer team which created the api and is "attached" to the responsible for the infrastructure is not able to trace the error cause it means the api lacks error info. firebase team should strongly consider add more information to the error in order to help people to solve it.

    what i know.

    1 - is 100% not an internet error.
    just before doing the auth request my app tests the users internet connection in order to avoid this type of problem
    2- it is not about old devices. i got this error happening from android 5 to 9
    3 - it consistly happens to same users.
    As i said i have a support chat in my app where users talk to me. once a girl reported this problem then i asked her to reinstall the app and restart the phone... problem still persisted... this girl complained about this error for 4 days in a row until decided stop trying to use the app

    this is a screenshot of how it looks on crashlytics

    https://ibb.co/hdP2r87

  5. malcolmdeck commented on Sep 21, 2020

    @malcolmdeck
    Contributor

    I understand your frustration, and appreciate you providing more detail. We'll take a look to see if there's anything we can do to help you. If you need this responded to more urgently, I advise that you contact Firebase Support.

    Thanks,
    ~Malcolm

  6. erichints commented on Apr 26, 2021

    @erichints

    Hi, did you get a working solution for this?
    It seems that our production app is facing similar intermittent issue with authentication. If it happens to a device it seems to persist.

    Thanks
    Eric

  7. malcolmdeck commented on Apr 26, 2021

    @malcolmdeck
    Contributor

    I don't know about the initial reporter, but I haven't received any reports of people who were able to reliably reproduce this. If you get any information that can help us resolve the issue, please do report back with some details - I would love to fix this

  8. bolds07 commented on Apr 26, 2021

    @bolds07
    Author

    To reliably reproduce a problem that is related to some inner process of an api which i dont have access to the source nor any way to attach a debugger is very difficult

    I'm still facing the problem, it is sporadic, happens in production with a range of devices... before trying to authenticate with firebase I always do 2 checks

    1- ping my webserver to be sure user has internet connection
    2- check if google play api is available [because i had problems that were related to this in the past]

    even with both verifications i still get this issue on about 0.5% of sessions daily...

    I didn't try to debug further because from my end is much easier try to find a workaround than try to debug

  9. j22purikas commented on Apr 27, 2021

    @j22purikas

    @malcolmdeck, I take over @erichints comment. Unfortunately, we are not able to reproduce it.
    Some users started complaining that the login spinner keeps spinning and nothing happens. That means addOnSuccessListener nor addOnFailureListener is not called(Maybe it takes a very long time before we get a callback from signInWithCustomToken, not sure, they didn't wait so long). For one user, seemed like turning on/off wifi helped to make it work(also cannot be sure 100%).

    It feels like something is not working correctly, how firebase detects network connection or smth.

  10. GEverding commented on Jul 6, 2021

    @GEverding

    @j22purikas we see similar behaviour. I opened another ticket to dive into this behaviour #2765

  11. YSDC commented on Dec 12, 2022

    @YSDC

    to not let this thread die, I also posted similar issue in thread #2765

  12. Ajohnie commented on Jul 1, 2023

    @Ajohnie

    We faced a similar challenge in our production app. In our case, when a user changed their network connection from WIFI to mobile data, this happened. I am not sure if this is the root cause but it was consistent among multiple users.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions