I have packet analyzed my dns packets and I am still getting
UnknownHostException with a successful resolution on the emulator.

On Jan 17, 7:53 pm, Indicator Veritatis <mej1...@yahoo.com> wrote:
> Excellent post! I have only one small detail to add; it might actually
> turn out to be important, though I can't guarantee it. That detail is:
> DNS is almost always implemented using UDP for transport, not TCP, so
> there is none of TCP's measures to try to provide guaranteed delivery.
> Instead, the DNS client (a.k.a. the 'resolver') will retry a few
> times, then quit. How many times is up to the implementer.
>
> So though it may be difficult (since the Exception is random), I would
> consider it worth the bother to run Wireshark captures while doing the
> DNS search, and see what shows up when the OP get
> UnknownHostException.
>
> Now here is why my one point may be so relevant: the resolver is
> linked into the Linux application, so it can be different even for two
> different applications running on the same phone (though this is
> unlikely, especially if all are Android Java apps). Then there are
> configuration parameters passed to the resolver function calls. It is
> not a separate daemon as are most application level networking
> clients. So this could explain why the OP gets the failures only with
> this one application and not with other hosts or other applications on
> the same phone.
>
> So is the OP's application pure Android Java, or did he use the NDK?
> What about other applications running on the same phone? If all
> Android Java applications fail randomly just like the OP's own
> application, while some NDK applications work, then the problem is
> most likely with the phone's implementation of the resolver for
> Android Java (less likely the WiFi itself). But again, to really be
> sure what is going on, LogCat is not enough: we need the Wireshark
> captures, preferebly on with tehe failure adn one without, so that we
> can see how your phone implemented and configured the resolver: not
> everyone uses BIND.
>
> There are other variations possible. To distinguish between them, the
> Wireshark captures are the way to go.
>
> Finally, whose DNS server is the OP using? Google's is pretty good,
> response time is excellent. And it is quite capable of handling either
> IPv6 or IPv4. If he sets up a local DNS server, not only can he have
> total control, it makes it a lot easier to GET those Wireshark
> captures. Unfortunately, we can't run Wireshark on even a rooted
> Android phone. If you can't do the local server, and can't run
> Wireshark on the WiFi AP, then it may even be worth the effort to fake
> it, running a simple Java program inside your LAN that does not do the
> whole DNS, but spits back a canned DNS response. I have done this
> before with success.
>
> On Jan 12, 11:00 pm, Bob Kerns <r...@acm.org> wrote:
>
>
>
>
>
>
>
> > UnknownHostException means your device was unable to get a positive
> > response to the DNS query trying to look up the hostname.
>
> > It doesn't distinguish between "We couldn't talk to the DNS server",
> > "we have no network connection right now", "we have never even HEARD
> > of net work, what's that?", or "we carefully and thoroughly discussed
> > it with the DNS server, which in turn discussed it with the relevant
> > authoritative DNS servers, and can conclusively state, that the host
> > named does not exist at this time".
>
> > What you CAN say, is it never got to the point of actually trying to
> > talk to that host, because it didn't get enough information to do so.
> > That is, it is not saying "we've heard of that host, but it doesn't
> > seem to be there".
>
> > The most likely cause is a temporary failure in your wifi connection,
> > just as it was trying the DNS lookup. But the DNS server itself could
> > be to blame, or if it's a DNS server on your site, the connection
> > upstream, or an upstream DNS server could be to blame.
>
> > I use my local wifi server as a DNS server. It's been giving me
> > problems like this lately, even on wired connections. Plus, it is not
> > compatible with IPv6, so I'm going to need to upgrade it soon. I could
> > configure it to advertise OpenDNS servers instead (which is what it
> > itself is using), but have slightly longer lookups and no cached data
> > if the cable connection hiccups. If it's the cable connection that's
> > at fault, then I'll have these problems anyway. It won't be easy to
> > track down.
>
> > On Jan 12, 8:44 pm, Ankur Avlani <ankuravl...@gmail.com> wrote:
>
> > > Unfortunately, the server is not local.
>
> > > On Wed, Jan 12, 2011 at 4:15 PM, Dan <king...@gmail.com> wrote:
> > > > Hello All,
>
> > > > I have had this error both on emulator and a Motorola Droid while
> > > > using a WIFI connection.  I have surrounded the http request with WIFI
> > > > state checks and before and after WIFI is reported state 3
> > > > (WIFI_STATE_ENABLED) and a connection speed of 54 . I have also
> > > > confirmed, using an adb shell with the emulator, that the emulator
> > > > cannot ping the website in question giving a domain resolution error.
> > > > To compare notes with Ankur, is the server on your LAN and the IP used
> > > > internal? mine is.
>
> > > > I have also tried AndroidHttpClient which does work on the same url.
>
> > > > -Dan
>
> > > > On Jan 12, 12:23 pm, Ankur Avlani <ankuravl...@gmail.com> wrote:
> > > > > True, I agree with what you say.  Its just that I feel, other apps 
> > > > > should
> > > > > also break or give error.
>
> > > > > Anywayz, Thanks a lot for your inputs.
>
> > > > > regards,
> > > > > Ankur.
>
> > > > > On Wed, Jan 12, 2011 at 12:17 PM, Brill Pappin <br...@pappin.ca> 
> > > > > wrote:
> > > > > > Well i suppose thats possible if your messing with the network 
> > > > > > stack,
> > > > > > but it's pretty low level for Java/Android.
> > > > > > I guess its also possible that the Android version you have has a
> > > > > > crappy stack or driver... or you have rooted it and have been 
> > > > > > messing
> > > > > > around under the covers so to speak.
>
> > > > > > There is nothing in Android really that would allow you to mess it 
> > > > > > up
> > > > > > that badly AFAIK, so I doubt it's your application causing the 
> > > > > > problem
> > > > > > if your not specifically getting under the covers.
>
> > > > > > However, the meaning of the exception is clear:
>
> > > > > >http://download.oracle.com/javase/1.4.2/docs/api/java/net/UnknownHost.
> > > > ..
> > > > > > and your app doesn't really control the process of translating a
> > > > > > domain to an ip.
>
> > > > > > - Brill Pappin
>
> > > > > > On Jan 12, 2:54 pm, Ankur Avlani <ankuravl...@gmail.com> wrote:
> > > > > > > Somehow I have this feeling it is related to my app only.  Other 
> > > > > > > apps
> > > > on
> > > > > > the
> > > > > > > phone, I don't see any such issue.  Even when browsing on my 
> > > > > > > phone, I
> > > > > > don't
> > > > > > > see any error.
>
> > > > > > > On Wed, Jan 12, 2011 at 11:41 AM, Kumar Bibek 
> > > > > > > <coomar....@gmail.com>
> > > > > > wrote:
> > > > > > > > By Wi-Fi, I meant, you phone's Wi-Fi could be turning on and 
> > > > > > > > off.
> > > > There
> > > > > > is
> > > > > > > > no other reason I can think of. It happens for me as well,
> > > > sometimes.
>
> > > > > > > > Kumar Bibek
> > > > > > > >http://techdroid.kbeanie.com
> > > > > > > >http://www.kbeanie.com
>
> > > > > > > > On Thu, Jan 13, 2011 at 1:10 AM, Ankur Avlani <
> > > > ankuravl...@gmail.com
> > > > > > >wrote:
>
> > > > > > > >> I am sorry, that somehow doesn't convince me.  I am connected 
> > > > > > > >> to
> > > > the
> > > > > > same
> > > > > > > >> wifi on my laptop and i never see any web page load error on my
> > > > > > laptop.
>
> > > > > > > >> On Wed, Jan 12, 2011 at 11:38 AM, Kumar Bibek <
> > > > coomar....@gmail.com
> > > > > > >wrote:
>
> > > > > > > >>> Yup, then it's a problem with your Wi-Fi.
>
> > > > > > > >>> Kumar Bibek
> > > > > > > >>>http://techdroid.kbeanie.com
> > > > > > > >>>http://www.kbeanie.com
>
> > > > > > > >>> On Thu, Jan 13, 2011 at 1:07 AM, Ankur Avlani <
> > > > ankuravl...@gmail.com
> > > > > > >wrote:
>
> > > > > > > >>>> I am connected to network, I am on Wifi.  If i try again it
> > > > works.
> > > > > >  Its
> > > > > > > >>>> just random.
>
> > > > > > > >>>> On Wed, Jan 12, 2011 at 11:34 AM, Kumar Bibek <
> > > > coomar....@gmail.com
> > > > > > >wrote:
>
> > > > > > > >>>>> This error/exception comes because of no network 
> > > > > > > >>>>> connectivity.
>
> > > > > > > >>>>> Kumar Bibek
> > > > > > > >>>>>http://techdroid.kbeanie.com
> > > > > > > >>>>>http://www.kbeanie.com
>
> > > > > > > >>>>> On Thu, Jan 13, 2011 at 1:02 AM, Ankur Avlani <
> > > > > > ankuravl...@gmail.com>wrote:
>
> > > > > > > >>>>>> Hi All,
>
> > > > > > > >>>>>> I am developing an application on Android.  I have seen 
> > > > > > > >>>>>> that
> > > > at
> > > > > > times
> > > > > > > >>>>>> when I try to connect using HttpURLConnection, for getting 
> > > > > > > >>>>>> an
> > > > > > Image or
> > > > > > > >>>>>> anydata, I get the following error:
>
> > > > > > > >>>>>> 01-12 11:24:05.073: WARN/System.err(16780):
> > > > > > > >>>>>> java.net.UnknownHostException: Host is unresolved:
> > > >www.XXX.com:80.
>
> > > > > > > >>>>>> Note: I get this error on my Motorolla Droid and not in
> > > > emulator.
>
> > > > > > > >>>>>> Any ideas?
>
> > > > > > > >>>>>> Thanks,
> > > > > > > >>>>>> Ankur
>
> > > > > > > >>>>>>  --
> > > > > > > >>>>>> You received this message because you are subscribed to the
> > > > Google
> > > > > > > >>>>>> Groups "Android Developers" group.
> > > > > > > >>>>>> To post to this group, send email to
> > > > > > > >>>>>> android-developers@googlegroups.com
> > > > > > > >>>>>> To unsubscribe from this group, send email to
> > > > > > > >>>>>> android-developers+unsubscr...@googlegroups.com<android-developers%2Bunsubs
> > > > > > > >>>>>>  cr...@googlegroups.com><android-developers%2Bunsubs
> > > > cr...@googlegroups.com><android-developers%2Bunsubs
> > > > > > cr...@googlegroups.com>
> > > > > > > >>>>>> For more options, visit this group at
> > > > > > > >>>>>>http://groups.google.com/group/android-developers?hl=en
>
> > > > > > > >>>>>  --
> > > > > > > >>>>> You received this message because you are subscribed to the
> > > > Google
> > > > > > > >>>>> Groups "Android Developers" group.
> > > > > > > >>>>> To post to this group, send email to
> > > > > > > >>>>> android-developers@googlegroups.com...
>
> read more »

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to