Unknown Host Exception - BackendlessPro - License ID: 1476971703098

I also get these intermittently, usually on launch of our app. I just saw this on my dev device. I originally just attributed these to spotty internet when I see it in the wild, but I just saw this in my house on stable wifi, and the apps map loaded fine while backendless failed to connect.

11-03 23:52:32.581 29518-29610/dinnerdeal.androiddev.customer W/System.err: java.net.UnknownHostException: Unable to resolve host “dinnerdeal.backendless.com”: No address associated with hostname
11-03 23:52:32.581 29518-29591/dinnerdeal.androiddev.customer W/CrashlyticsCore: Received null settings, skipping initialization!
11-03 23:52:32.581 29518-29610/dinnerdeal.androiddev.customer W/System.err: at java.net.Inet6AddressImpl.lookupHostByName(Inet6AddressImpl.java:125)
11-03 23:52:32.581 29518-29610/dinnerdeal.androiddev.customer W/System.err: at java.net.Inet6AddressImpl.lookupAllHostAddr(Inet6AddressImpl.java:74)
11-03 23:52:32.581 29518-29610/dinnerdeal.androiddev.customer W/System.err: at java.net.InetAddress.getAllByName(InetAddress.java:752)
11-03 23:52:32.581 29518-29610/dinnerdeal.androiddev.customer W/System.err: at okhttp3.Dns$1.lookup(Dns.java:39)
11-03 23:52:32.581 29518-29610/dinnerdeal.androiddev.customer W/System.err: at okhttp3.internal.http.RouteSelector.resetNextInetSocketAddress(RouteSelector.java:173)
11-03 23:52:32.581 29518-29610/dinnerdeal.androiddev.customer W/System.err: at okhttp3.internal.http.RouteSelector.nextProxy(RouteSelector.java:139)
11-03 23:52:32.581 29518-29610/dinnerdeal.androiddev.customer W/System.err: at okhttp3.internal.http.RouteSelector.next(RouteSelector.java:81)
11-03 23:52:32.582 29518-29610/dinnerdeal.androiddev.customer W/System.err: at okhttp3.internal.http.StreamAllocation.findConnection(StreamAllocation.java:172)
11-03 23:52:32.582 29518-29610/dinnerdeal.androiddev.customer W/System.err: at okhttp3.internal.http.StreamAllocation.findHealthyConnection(StreamAllocation.java:123)
11-03 23:52:32.582 29518-29610/dinnerdeal.androiddev.customer W/System.err: at okhttp3.internal.http.StreamAllocation.newStream(StreamAllocation.java:93)
11-03 23:52:32.582 29518-29610/dinnerdeal.androiddev.customer W/System.err: at okhttp3.internal.http.HttpEngine.connect(HttpEngine.java:296)
11-03 23:52:32.582 29518-29610/dinnerdeal.androiddev.customer W/System.err: at okhttp3.internal.http.HttpEngine.sendRequest(HttpEngine.java:248)
11-03 23:52:32.582 29518-29610/dinnerdeal.androiddev.customer W/System.err: at okhttp3.RealCall.getResponse(RealCall.java:243)
11-03 23:52:32.582 29518-29610/dinnerdeal.androiddev.customer W/System.err: at okhttp3.RealCall$ApplicationInterceptorChain.proceed(RealCall.java:201)
11-03 23:52:32.582 29518-29610/dinnerdeal.androiddev.customer W/System.err: at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:163)
11-03 23:52:32.582 29518-29610/dinnerdeal.androiddev.customer W/System.err: at okhttp3.RealCall.execute(RealCall.java:57)
11-03 23:52:32.582 29518-29610/dinnerdeal.androiddev.customer W/System.err: at dinnerdeal.android.customer.MyApp$1.run(MyApp.java:99)
11-03 23:52:32.582 29518-29610/dinnerdeal.androiddev.customer W/System.err: Caused by: android.system.GaiException: android_getaddrinfo failed: EAI_NODATA (No address associated with hostname)
11-03 23:52:32.582 29518-29610/dinnerdeal.androiddev.customer W/System.err: at libcore.io.Posix.android_getaddrinfo(Native Method)
11-03 23:52:32.582 29518-29610/dinnerdeal.androiddev.customer W/System.err: at libcore.io.ForwardingOs.android_getaddrinfo(ForwardingOs.java:55)
11-03 23:52:32.582 29518-29610/dinnerdeal.androiddev.customer W/System.err: at java.net.Inet6AddressImpl.lookupHostByName(Inet6AddressImpl.java:106)
11-03 23:52:32.582 29518-29610/dinnerdeal.androiddev.customer W/System.err: … 16 more

Hello Allen,

Excuse us for delay. Are you still experience any issues?

Regards

Hi Allen.
I can assume several reasons of this problem.
Firstly i want to note, that there are no invocations from any of backendless sdk methods. You use third party lib ‘okhttp3’ and this lib is not able to properly resolve host address. From the stacktrace i see that it tries to do this through IPv6 protocol - and this may be a problem, because not all custom DNS support IPv6.
Try to set IPv4 forcibly for requests with okhttp3 lib.

Okay so I’ve finally been able to get some insight on this issue via some remote logs when we see the unknown host exception in production. I added some code to test connectivity with the following when we see the exception:

http://www.google.com.au
http://dinnerdeal.backendless.com
http://52.65.139.218

I’d say about half the time, the user has actually lost service and I get a fail for all 3 test cases, but the other half of the time, I see a fail for just http://dinnerdeal.backendless.com and a pass on the other two, which leads me to believe this is in fact a DNS issue.

Is there anything we can do to combat this? Would it be risky to use the static ip in the setUrl?

Is the test done on a mobile device or in Cloud Code?

mobile devices in production

Hello Allen,

This is a very useful investigation, thank you! We discussed the possible reasons for the resolve problem and here’s what we came up with.

The hostname dinnerdeal.backendless.com is hosted on AWS Route53. If there was a problem with this service, we’d definitely hear about that too, since lots of resources are hosted there. Thus, we’ll put off the possibility of problems on Route53 as they’re totally minimal.

The dinnerdeal.backendless.com domain is then resolved to the load balancer’s hostname, which for your installation is http://dinnerdeal-app-lb0-341386954.ap-southeast-2.elb.amazonaws.com/. As a little step further in your investigation and error handling strategy, you could try to issue a request to this address when dinnerdeal.backendless.com cannot be resolved. Though I personally think that it’s a pretty poor strategy to adopt, since if the problem is with a local DNS, this shouldn’t help much.

Now coming to the most probable reason: we believe it can be an issue with specific customers’ local DNS provider. To verify that, I can suggest you to follow the instructions here: https://developers.google.com/speed/public-dns/docs/troubleshooting. The first thing to do in case of problem is to check whether dinnerdeal.backendless.com can be resolved via https://dns.google.com/. If it does resolve, then you’d have to trace the request from the client to see at which point the DNS error happens. I’m not sure if it is possible from the app’s code, this I believe you’ll have to find out with your engineering team. Probably the library you use (okhttp) can provide some tools for that.

After all, I’d say that using the static IP in setUrl() would probably not be a good solution since I’m not sure Amazon provides you any guarantees regarding the IP being static. Though of course you may have some generic error handler which would retry the request by doing something like the following:

setUrl( static-ip );
retryRequest();
setUrl( dinnerdeal.backendless.com );

This would probably help in some cases. But if the problem is indeed with a DNS of the client’s side, I think it would be more correct to inform the client that his DNS settings fail to handle the dinnerdeal.backendless.com domain name - there is a possibility that the client would know better why this happens.