Skip to content
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

Problems with DNS resolution #3919

Closed
jonbulica99 opened this issue Mar 12, 2018 · 40 comments
Closed

Problems with DNS resolution #3919

jonbulica99 opened this issue Mar 12, 2018 · 40 comments
Labels
stackoverflow Referred to stackoverflow

Comments

@jonbulica99
Copy link

I've had this happen to a good 10% of my devices, affecting ~1000 users. However, I cannot seem to reproduce this issue. It only happens when connected over Wifi, and multiple users have confirmed me they weren't behind any captive portals or anything. They could access the url normally when typing it into a browser. There isn't any good indicator this is a vendor-specific issue either. My statistics show a majority of samsung devices,
grafik
but then again, it works flawlessly on my samsung test device. I don't know what to make of it. Here's the stack trace:

java.net.UnknownHostException
Unable to resolve host "<valid hostname>": No address associated with hostname
java.net.InetAddress.lookupHostByName (InetAddress.java:394)
java.net.InetAddress.getAllByNameImpl (InetAddress.java:236)
java.net.InetAddress.getAllByName (InetAddress.java:214)
arrow_right
okhttp3.Dns$1.lookup (Dns.java:40)
okhttp3.internal.connection.RouteSelector.resetNextInetSocketAddress (RouteSelector.java:185)
okhttp3.internal.connection.RouteSelector.nextProxy (RouteSelector.java:149)
okhttp3.internal.connection.RouteSelector.next (RouteSelector.java:84)
okhttp3.internal.connection.StreamAllocation.findConnection (StreamAllocation.java:214)
okhttp3.internal.connection.StreamAllocation.findHealthyConnection (StreamAllocation.java:135)
okhttp3.internal.connection.StreamAllocation.newStream (StreamAllocation.java:114)
okhttp3.internal.connection.ConnectInterceptor.intercept (ConnectInterceptor.java:42)
okhttp3.internal.http.RealInterceptorChain.proceed (RealInterceptorChain.java:147)
okhttp3.internal.http.RealInterceptorChain.proceed (RealInterceptorChain.java:121)
okhttp3.internal.cache.CacheInterceptor.intercept (CacheInterceptor.java:93)
okhttp3.internal.http.RealInterceptorChain.proceed (RealInterceptorChain.java:147)
okhttp3.internal.http.RealInterceptorChain.proceed (RealInterceptorChain.java:121)
okhttp3.internal.http.BridgeInterceptor.intercept (BridgeInterceptor.java:93)
okhttp3.internal.http.RealInterceptorChain.proceed (RealInterceptorChain.java:147)
okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept (RetryAndFollowUpInterceptor.java:126)
okhttp3.internal.http.RealInterceptorChain.proceed (RealInterceptorChain.java:147)
okhttp3.internal.http.RealInterceptorChain.proceed (RealInterceptorChain.java:121)
okhttp3.RealCall.getResponseWithInterceptorChain (RealCall.java:200)
okhttp3.RealCall.execute (RealCall.java:77)
retrofit2.OkHttpCall.execute (OkHttpCall.java:180)
retrofit2.adapter.rxjava2.CallExecuteObservable.subscribeActual (CallExecuteObservable.java:41)
io.reactivex.Observable.subscribe (Observable.java:10151)
retrofit2.adapter.rxjava2.BodyObservable.subscribeActual (BodyObservable.java:34)
io.reactivex.Observable.subscribe (Observable.java:10151)
io.reactivex.internal.operators.observable.ObservableSingleSingle.subscribeActual (ObservableSingleSingle.java:35)
io.reactivex.Single.subscribe (Single.java:2517)
io.reactivex.internal.operators.single.SingleSubscribeOn$SubscribeOnObserver.run (SingleSubscribeOn.java:89)
io.reactivex.Scheduler$1.run (Scheduler.java:131)
io.reactivex.internal.schedulers.ScheduledRunnable.run (ScheduledRunnable.java:59)
io.reactivex.internal.schedulers.ScheduledRunnable.call (ScheduledRunnable.java:51)

If you need more information, don't hesitate to ask.

@yschimke yschimke added the stackoverflow Referred to stackoverflow label Mar 13, 2018
@yschimke
Copy link
Collaborator

This is a fairly generic networking error with a lot of routine reasons it can happen. I suggest asking on stackoverflow where you will get a broader set of eyes. It's unlikely it is specifically an OkHttp error.

Feel free to drop your Stackoverflow question here as a reply.

@renatopeterman
Copy link

I'm not sure if this is a generic networking error. I always saw this a lot on fabric but I wasn't able to debug, but now something weird just happened with a user.
I have two apps (lite version and pro version), exactly same codebase and exactly same API hostname.
The user has the two apps installed on Samsung device, but, the pro version is returning java.net.UnknownHostException Unable to resolve host "<valid hostname>": No address associated with hostname and the lite one is working normally.

How's that possible?

@jarrodrobins
Copy link

Did you ever get anywhere with this issue @renatopeterman? I have the same issue, it's one of our biggest issues coming in via Fabric and we are unable to reproduce it.

@jahk88
Copy link

jahk88 commented Dec 26, 2018

Hello fellows, have anybody got a solution to this issue? I've the same situation, this is one of our biggest issues too. I will appreciate if someone let me know how solved this thing. Regards

@amirlivneh
Copy link
Collaborator

You can try using an implementation of the DNS interface that falls back to Google DNS.

@shah-nishant
Copy link

Hi everyone, was anyone able to figure out a solution for this? We are facing same issues with our app

@xiangyangyang
Copy link

check your device is opened wifi?

@wildseansy
Copy link

wildseansy commented May 28, 2020

@jonbulica99 - did you ever figure out what was going on? We're getting the same issue and it is basically bricking our app for some android users 😰 , mostly samsung

@yschimke
Copy link
Collaborator

Do you have first hand experience with it happening when it definitely shouldn't?

This looks like the behaviour you get on newer Android versions when backgrounded and doze mode is on etc. Could these errors be logged by your app while backgrounded and not allowed access to the network? But then testing with a browser (by definition in foreground) the request will succeed?

@wildseansy
Copy link

wildseansy commented May 28, 2020

@yschimke - I haven't been able to repro on my own.

We're just getting reports of some users failing to access our app, and we have a retry screen. Hitting retry (which re-submits the requests) and just restarting the app both don't resurrect their session immediately. One user went and changed his notification settings, and then started the app. For some reason issue went away permanently for him, and then changing the notification settings back to their old status didn't recreate the issue, so it's unclear if that actually did anything.

@yschimke
Copy link
Collaborator

Thanks, that's useful. But I don't have a good answer for you at the moment.

@wildseansy
Copy link

Thanks, that's useful. But I don't have a good answer for you at the moment.

Appreciate the suggestion re: doze mode, I'm going to test this on some Samsung devices and see if I can repro.

@yschimke
Copy link
Collaborator

Airplane mode fails this way also, but then would affect all apps. If you have a crash reporter app, it would be interesting to see what else correlates with the errors.

java.net.UnknownHostException: Unable to resolve host "google.com": No address associated with hostname
at java.net.Inet6AddressImpl.lookupHostByName(Inet6AddressImpl.java:156)
at java.net.Inet6AddressImpl.lookupAllHostAddr(Inet6AddressImpl.java:103)
at java.net.InetAddress.getAllByName(InetAddress.java:1152)
at okhttp3.Dns$Companion$DnsSystem.lookup(Dns.kt:49)
at okhttp3.internal.connection.RouteSelector.resetNextInetSocketAddress(RouteSelector.kt:164)
at okhttp3.internal.connection.RouteSelector.nextProxy(RouteSelector.kt:129)
at okhttp3.internal.connection.RouteSelector.next(RouteSelector.kt:71)

@yschimke
Copy link
Collaborator

See #3974 (comment)

@yschimke
Copy link
Collaborator

FWIW adb enhanced is useful for testing similar OS modes https://github.com/ashishb/adb-enhanced

@wildseansy
Copy link

wildseansy commented May 28, 2020

Airplane mode fails this way also, but then would affect all apps. If you have a crash reporter app, it would be interesting to see what else correlates with the errors...

Thanks for the reference, will research further. We know users experiencing this issue aren't on airplane mode from talking to them

After surveying a few of the users, it appears the user ONLY happens on wifi. Our app works fine on cellular data.

More details on our issue

~80% of our app is in React Native, on v0.62.2. We got this issue after upgrading from 0.61.5 to 0.62.2, but that might be unrelated. We also have a native part of our app where we directly use retrofit and okhttp. We use retrofit 2.8.0 so that sets our okhttp to v3.14.7. In an attempt to fix, we have pinned retrofit to 2.6.4 so its version for okhttp is 3.12.0, which matches what RN also expects. We haven't seen reports of any other users getting this issue upgrading to RN's 0.62.2, so we thought this might be due to our version mismatch of okhttp.

Finally, the only adjustment we really make to okhttp in our app:

      NetworkingModule.setCustomClientBuilder {
        it.retryOnConnectionFailure(false)
      }

This is because we were seeing that requests to multipart uploads were queuing up for retry automatically on failure. Later we would sometimes see these uploads get retried, and it would overwhelm our services sometimes with hundreds of uploads with the same image.

Here are a few of our issues we have seen coming in through our monitoring.

java.net.UnknownHostExceptionForwardingOs.java:58
java.net.UnknownHostException Unable to resolve host "s3-us-west-2.amazonaws.com": No address associated with hostname 
    Inet6AddressImpl.java:141 java.net.Inet6AddressImpl.lookupHostByName
    Inet6AddressImpl.java:90 java.net.Inet6AddressImpl.lookupAllHostAddr
    InetAddress.java:787 java.net.InetAddress.getAllByName
    Dns.java:39 okhttp3.Dns$-CC.lambda$static$0
    Unknown okhttp3.-$$Lambda$Dns$mTkNcZf2K4euny3_jks6Cac6Az0.lookup
    RouteSelector.java:171 okhttp3.internal.connection.RouteSelector.resetNextInetSocketAddress
    RouteSelector.java:135 okhttp3.internal.connection.RouteSelector.nextProxy
    RouteSelector.java:84 okhttp3.internal.connection.RouteSelector.next
    ExchangeFinder.java:187 okhttp3.internal.connection.ExchangeFinder.findConnection
    ExchangeFinder.java:108 okhttp3.internal.connection.ExchangeFinder.findHealthyConnection
    ExchangeFinder.java:88 okhttp3.internal.connection.ExchangeFinder.find
    Transmitter.java:169 okhttp3.internal.connection.Transmitter.newExchange
    ConnectInterceptor.java:41 okhttp3.internal.connection.ConnectInterceptor.intercept
java.net.UnknownHostException Unable to resolve host "s3-us-west-2.amazonaws.com": No address associated with hostname 
    Inet6AddressImpl.java:126 java.net.Inet6AddressImpl.lookupHostByName
    Inet6AddressImpl.java:105 java.net.Inet6AddressImpl.lookupAllHostAddr
    InetAddress.java:1154 java.net.InetAddress.getAllByName
    Dns.java:39 okhttp3.Dns$-CC.lambda$static$0
    Unknown okhttp3.-$$Lambda$Dns$mTkNcZf2K4euny3_jks6Cac6Az0.lookup
    RouteSelector.java:171 okhttp3.internal.connection.RouteSelector.resetNextInetSocketAddress
    RouteSelector.java:135 okhttp3.internal.connection.RouteSelector.nextProxy
    RouteSelector.java:84 okhttp3.internal.connection.RouteSelector.next
    ExchangeFinder.java:187 okhttp3.internal.connection.ExchangeFinder.findConnection
    ExchangeFinder.java:108 okhttp3.internal.connection.ExchangeFinder.findHealthyConnection
    ExchangeFinder.java:88 okhttp3.internal.connection.ExchangeFinder.find
    Transmitter.java:169 okhttp3.internal.connection.Transmitter.newExchange
    ConnectInterceptor.java:41 okhttp3.internal.connection.ConnectInterceptor.intercept
    RealInterceptorChain.java:142 okhttp3.internal.http.RealInterceptorChain.proceed
    RealInterceptorChain.java:117 okhttp3.internal.http.RealInterceptorChain.proceed
    CacheInterceptor.java:94 okhttp3.internal.cache.CacheInterceptor.intercept
java.lang.reflect.UndeclaredThrowableExceptionNoServiceActivity
java.lang.reflect.UndeclaredThrowableException
    Unknown:-1 $Proxy31.downloadAsset
    AssetManager.kt:112 com.openfit.openfit.app.AssetManager.downloadAndWrite
    AssetManager.kt:92 com.openfit.openfit.app.AssetManager.downloadAsset
    AssetManager.kt:48 com.openfit.openfit.app.AssetManager$downloadSessionAssets$$inlined$repeat$lambda$1.invokeSuspend
    ContinuationImpl.kt:33 kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith
    Dispatched.kt:241 kotlinx.coroutines.DispatchedTask.run
    CoroutineScheduler.kt:594 kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely
    CoroutineScheduler.kt:60 kotlinx.coroutines.scheduling.CoroutineScheduler.access$runSafely
    CoroutineScheduler.kt:740 kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run

Caused by: java.net.UnknownHostException Unable to resolve host "s3-us-west-2.amazonaws.com": No address associated with hostname 

@wildseansy
Copy link

wildseansy commented Jun 1, 2020

For our app, issues are happening primarily on Samsung S9 and Note 10 with Android 10, only on Wifi. For what it's worth, I'm starting to believe it may be the same as these reports, might not be specific to Okhttp

@elkasvirElka
Copy link

Hello. @wildseansy
I am facing the same issue. Does not crash the app, but I have a lot of reports in crash analytics.
Did you figure it out?

@yschimke
Copy link
Collaborator

Do you have any contextual information

  • Device manufacturers
  • Android OS version
  • Background state
  • Wifi/Cell?
  • Proxy enabled?

@wildseansy
Copy link

I never figured it out completely. It seems from what I have seen, when a user doesn't have a connection, it corrupts the dns record as unreachable and mostly on samsung

Hello. @wildseansy
I am facing the same issue. Does not crash the app, but I have a lot of reports in crash analytics.
Did you figure it out?

@yschimke
Copy link
Collaborator

If you are particularly motivated you could experiment (A/B test) with Dns over HTTPs (okhttp-doh) as a fall back? Maybe try system dns first, and then follow up with dns over https if it fails, see whether you get results in that case. But there isn't a good fix from OkHttp as by default we rely on InetAddress.getAllByName which is obviously very standard system call.

@Zeg0
Copy link

Zeg0 commented Nov 18, 2021

I have the same error on my personal Huawei P30 pro VOG-L29 Android 10.1.0 Build 10.1.0.161(c431e23r2p5) both on WIFI and on mobile Data aswell. Turning phone completely off and on didn't fix it.

inputStream = httpConn.getInputStream(); // ERROR HERE java.net.UnknownHostException: Unable to resolve host "bot.whatismyipaddress.com": No address associated with hostname ........  at com.android.okhttp.Dns$1.lookup(Dns.java:41) .............. Caused by: android.system.GaiException: android_getaddrinfo failed: EAI_NODATA (No address associated with hostname) ............ java.net.Inet6AddressImpl.lookupHostByName(Inet6AddressImpl.java:135)

It is strange that it tries to resolve that address over dns with ipv6 implementation honestly. The related nameservers are cloudflare ones. The base domain whatismyipaddress.com has both ipv4 and ipv6 adresses. The subdomain bot.whatismyipaddress.com is supposed to work with these ip adresses as well (like in the browser it works) however from commandline windows nslookup also fails to get the address of the subdomain.

nslookup whatismyipaddress.com
Server:  fritz.box
Address:  192.168.178.1

Nicht autorisierende Antwort:
Name:    whatismyipaddress.com
Addresses:  2606:4700::6810:9b24
          2606:4700::6810:9a24
          104.16.154.36
          104.16.155.36
>>
>>        
nslookup bot.whatismyipaddress.com
Server:  fritz.box
Address:  192.168.178.1

Name:    bot.whatismyipaddress.com
>>
>>

It could be a subdomain revolving issue? I suppose android native programming is "as stupid as windows nslookup" while resolving the host from a specific version onward? Maybe the browser implementation somehow get's around this and uses the ip address of the top domain if the subdomain fails?

@Zeg0
Copy link

Zeg0 commented Nov 18, 2021

Hey there. This seems to be a good aproach!

After two hours i got this:

public void dostuff(){
                    ...
                    targeturl = "http://bot.whatismyipaddress.com/";
                    response = _makeSimpleHttpRequest(targeturl, "GET", "",true); 
                    ...
}
 public static String _makeSimpleHttpRequest(String targetUrl, String methodGetPostX, String postBody, boolean useSelfImplementedDNSwithFallbackTopdomain) throws MalformedURLException, IOException, NotImplementedException{
String responseline = "";
        String temp = "";
        HttpURLConnection httpConn = null;
        InputStream inputStream = null;
        InputStreamReader inputStreamReader = null;
        BufferedReader bufferedReader = null;
        OutputStream outputStream = null;
        OutputStreamWriter outputStreamWriter = null;
        BufferedWriter bufferedWriter = null;

        try {
            java.net.URL url = null;
            if(!useSelfImplementedDNSwithFallbackTopdomain){
                url = new java.net.URL(targetUrl); // system default DNS resolver
            }
            else{
                String baseDomainName = _getDomainFromFullURL(targetUrl);
                String targetUrlReplacedDomainWithIP = targetUrl.replace(baseDomainName,_makeDnsLookupForDomainOrFallbackTopdomain(baseDomainName));
                url = new java.net.URL(targetUrlReplacedDomainWithIP); 
            }
            httpConn = (HttpURLConnection)url.openConnection(); // HERE THE ERROR OCCURED PREVIOUSLY, NOW THE IP GOT RESOLVED CORRECTLY BEFOREHAND, BUT SSL ERROR FOROBVIOUS REASON SINCE THE DOMAIN WAS REPLACED BY THE IP MANUALLY
}

public static String _getDomainFromFullURL(String url) throws URISyntaxException {
        URI uri = new URI(url);
        String domain = uri.getHost();
        return domain;
}

public static String _getRightSideOfStringSplitByFirstDot_TopDomainOfSubDomain(String stringWithDots_SubDomain){
        String[] splitByDot = stringWithDots_SubDomain.split("\\.");
        String topDomain="";
        for(int i = 1; i< splitByDot.length; i++){
            topDomain += splitByDot[i];
            if(i<splitByDot.length-1){
                topDomain += ".";
            }
        }
        return topDomain;
}
    
public static String _makeDnsLookupForDomainOrFallbackTopdomain(String domainName) throws UnknownHostException {
        String ipAddr = "";
        int i = 0;
        try{
            System.out.println("dns probe with fallback to top-domain ["+i+"]: " + domainName +" = ...");
            ipAddr = _makeDnsLookupForDomain(domainName);
            System.out.println("dns probe with fallback to top-domain ["+i+"]: " + domainName +" = " + ipAddr);
        } catch (UnknownHostException e){
            while(domainName.contains(".") && !domainName.endsWith(".") && !domainName.startsWith(".")){
                i++;
                domainName = _getRightSideOfStringSplitByFirstDot_TopDomainOfSubDomain(domainName);
                System.out.println("dns probe with fallback to top-domain ["+i+"]: " + domainName +" = ...");
                try{
                    ipAddr = _makeDnsLookupForDomain(domainName);
                    System.out.println("dns probe with fallback to top-domain ["+i+"]: " + domainName +" = " + ipAddr);
                    break;
                } catch (UnknownHostException e2){
                    //
                    throw e2;
                }
            }
        }
        return ipAddr;
}

public static String _makeDnsLookupForDomain(String domainName) throws UnknownHostException {
        // http://www.avajava.com/tutorials/lessons/how-do-i-use-a-host-name-to-look-up-an-ip-address.html
        InetAddress[] inetAddressArray = InetAddress.getAllByName(domainName/*"www.google.com"*/);
        //
        int selectThisEntryNumber = 0;
        if(inetAddressArray.length==1){
            selectThisEntryNumber = 0;
        }
        else if(inetAddressArray.length>1){
            Random random = new Random();
            int max = inetAddressArray.length-1;
            int min = 0;
            selectThisEntryNumber = random.nextInt(max - min + 1) + min; // number between max and min including both
        }
        else{
            // 0
            throw new UnknownHostException("Retrieved 0 addresses for this host: " + domainName);
        }
        String ipAddressString = inetAddressArray[selectThisEntryNumber].getHostAddress();
        return ipAddressString;
}   

Now the flow is:
GET https://bot.whatismyipaddress.com/
goes into my own DNS resolver which gets rid of the subdomain if UnknownHost-Exception occurs:

dns probe with fallback to top-domain [0]: bot.whatismyipaddress.com = ...
dns probe with fallback to top-domain [1]: whatismyipaddress.com = ...
dns probe with fallback to top-domain [1]: whatismyipaddress.com = 104.16.155.36

Now the call would be transformed to:
GET https://104.16.155.36/

However this throws SSL exception for obvious reasons (we just replaced the host and the certificate doesn't match to a floating ip!).

Now i am sure this was the problem for my issue. Since removing SSL Checks is not recommended do you guys have another idea how to make this work?

@Zeg0
Copy link

Zeg0 commented Nov 18, 2021

Update: It could be that cloudflare simply blocks me??? Now i can't open bot.whatismyipaddress.com in the browser aswell...

@Zeg0
Copy link

Zeg0 commented Nov 18, 2021

Update2: I changed the DNS resolver to system default again and tried with different URLs: http://bot.whatismyipaddress.com/ and GET https://checkip.dyndns.org/ and GET https://ipinfo.io/ip :

                    targeturl = "https://ipinfo.io/ip";
                    response = _makeSimpleHttpRequest(targeturl, "GET", "",true); 

The same issue occurs with checkip.dyndns.org which is also hosted on cloudflare. However the ipinfo.io works and is hosted on Google Domains according to Whois-Lookup! I Suppose there is an issue that cloudflare is simply blocking native calls from android devices, aka the admin of the website is to strict. Since there is also an issue in DNS resolving these cloudflare domains it could be some kind of active DDOS-Protection mechanisms filtering calls that look "to basic"? I think this is more an webserver admin issue we need to work around...

@sagrawal31
Copy link

For our users, this is happening quite frequently and we can't ask them to reconnect their Wifi or some hacks.

For an instance,

GaiException: android_getaddrinfo failed: EAI_NODATA (No address associated with hostname)
    at libcore.io.Linux.android_getaddrinfo(Linux.java)
    at libcore.io.ForwardingOs.android_getaddrinfo(ForwardingOs.java:73)
    at libcore.io.BlockGuardOs.android_getaddrinfo(BlockGuardOs.java:202)
    at libcore.io.ForwardingOs.android_getaddrinfo(ForwardingOs.java:73)
    at java.net.Inet6AddressImpl.lookupHostByName(Inet6AddressImpl.java:135)
...
(38 additional frame(s) were not displayed)

UnknownHostException: Unable to resolve host "[firebasestorage.googleapis.com](http://firebasestorage.googleapis.com/)": No address associated with hostname
    at java.net.Inet6AddressImpl.lookupHostByName(Inet6AddressImpl.java:156)
    at java.net.Inet6AddressImpl.lookupAllHostAddr(Inet6AddressImpl.java:103)
    at java.net.InetAddress.getAllByName(InetAddress.java:1152)
    at okhttp3.Dns$-CC.lambda$static$0(Dns.java:39)
    at okhttp3.-$$Lambda$Dns$mTkNcZf2K4euny3_jks6Cac6Az0.lookup

This issue is with Firebase API but the same also happens with our own domains.

@marwin1991
Copy link

why this isse is closed?

@yschimke
Copy link
Collaborator

We don't have a clean repro, and there seems to be some (circumstantial) evidence in #3919 (comment) that it appears outside OkHttp.

Do you have a simple repro we can investigate?

@zackees
Copy link

zackees commented Jul 16, 2023

It's not just an issue with OkHttp, I just ripped out OkHttp networking and replaced it with the HttpUrlConnection library from Google.

The good news is that this library is much much better at resolving the hostname from the DNS. The bad news is that the DNS resolution still fails sometimes.

My speculation is that some low level network state is borked and the HttpUrlConnection is just handling it better. But who knows.

Update: It's not. Dns still corrupts on Http Url as well.

@yschimke
Copy link
Collaborator

It's possible that stack is better at resolving DNS for the current network as that changes. But that's a guess.

@marwin1991
Copy link

Android has this problem but iOS works always fine.

@yschimke
Copy link
Collaborator

Is anyone here able to test with a build variant with an alternative OkHttp DNS impl?

@zackees
Copy link

zackees commented Jul 17, 2023

Is anyone here able to test with a build variant with an alternative OkHttp DNS impl?

Yes I switched it up to the native http library and got the same DNS corruption issues.

@joseandroidengineer
Copy link

Even though we can't really reproduce, is there at least a way to prevent these "crashes" from showing up on Firebase?
Also do these "crashes" happen for you guys in the background or while the app is running?

@artemcarabash
Copy link

Even though we can't really reproduce, is there at least a way to prevent these "crashes" from showing up on Firebase? Also do these "crashes" happen for you guys in the background or while the app is running?

I have received some Stack traces from our cusomers, and as it looks in our case it happens when the app is in the background and trying to make very first request to server on cold start. (It happens when we receive the push from firebase and trying to get some additional infos from backend to handle the push)

@yschimke
Copy link
Collaborator

As seen in #4789 (comment)

Android caches false results for 2 seconds, so if your app made a request in doze mode or similar, or the connection was down. Then it will fail until the Android cache is cleared after 2 seconds.

@vpmalley
Copy link

vpmalley commented Mar 21, 2024

As seen in #4789 (comment)

Android caches false results for 2 seconds, so if your app made a request in doze mode or similar, or the connection was down. Then it will fail until the Android cache is cleared after 2 seconds.

Are you implying that we should check for the current network state and the current doze state before using OkHttp to make sure we don't waste 2 seconds?

@yschimke
Copy link
Collaborator

No, maybe.

Android has some edge cases that will cause these types of persistent failures.

Short of handling them specifically, the best you can do is be aware of these android issues.

@yschimke
Copy link
Collaborator

yschimke commented May 2, 2024

Android fix for this https://cs.android.com/android/_/android/platform/frameworks/base/+/0fa9120b8f72916951b2d070afd6c3dfd3c13f77. I'm not sure if this goes into mainline modules, but I'm assuming not.

@zackees
Copy link

zackees commented May 2, 2024

Wait... so on network restore I can simply delay the network stack activation to get around this bug???

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stackoverflow Referred to stackoverflow
Projects
None yet
Development

No branches or pull requests