Network Unreachable (Socket.net Exception)

by himanshu jain » Sat, 06 Feb 2010 17:58:48 GMT


Sponsored Links
 Hi ,
               I am trying to connect to server through
HttpUrlConnection, but after sometimes it throws Socket.Net
Exception :Network Unreachable. I tired alarm manager to wake up the
phone and get the wifi lock but none seems to work .

Tell me what to do what should i check and alternative ?.


thanks

--



Network Unreachable (Socket.net Exception)

by himanshu jain » Sat, 06 Feb 2010 17:59:03 GMT


 Hi ,
               I am trying to connect to server through
HttpUrlConnection, but after sometimes it throws Socket.Net
Exception :Network Unreachable. I tired alarm manager to wake up the
phone and get the wifi lock but none seems to work .

Tell me what to do what should i check and alternative ?.


thanks

--


Sponsored Links


Network Unreachable (Socket.net Exception)

by Bob Kerns » Sun, 07 Feb 2010 02:59:37 GMT


 This error indicates that some router along the path (possibly your
local machine) has no route to the network you're trying to reach.

If you're running on a rooted phone, you can run traceroute <host> to
see the route to the host, if you have it; the busybox version works
well. This will show where the problem lies.

If the routing failure is on the local phone, 'route' will tell you
about the local routing tables, if you're using the BusyBox version of
'route'. You can also get it via 'cat /proc/net/route', but in a much
harder-to-understand format. Don't bother trying to figure out how to
use the built-in version; it's incomplete.

If it's not on the phone, it's not a phone problem. In any event, it's
definitely not an application problem, but a network failure (assuming
you're not trying to connect to some crazy address). It's something
you need to handle gracefully.

If the problem is not on the phone, and you're using wifi, you should
be able to observe the problem from any host on that network (at least
if it's getting the same default gateway, which would normally be the
case). So I'd try that first, rather than dealing with the limited
environment on the phone.




--



Network Unreachable (Socket.net Exception)

by himanshu jain » Sun, 07 Feb 2010 09:03:45 GMT


 @bob

I think i used connect to another website that sends news in order to
check whether it is wrong at network side or in my code.
Also my question is , can we really implement a service that runs in
background indefinitely and give us update if it is available .If yes,
then what parameters we should be aware of in sense of  phone
network ??.

please advice.

thank you





--



Network Unreachable (Socket.net Exception)

by himanshu jain » Sun, 07 Feb 2010 13:29:21 GMT


 @frank

Thank you very much let me look at those sample then i  will let you
know.

once again thanx




--



Network Unreachable (Socket.net Exception)

by himanshu jain » Sun, 07 Feb 2010 13:37:13 GMT


 @frank

Can you please tell me where i can find that sample code.

thanks





--



Network Unreachable (Socket.net Exception)

by Anthoni » Sun, 07 Feb 2010 17:36:41 GMT


 Hi himanshu,

The code, along with all other test / demo applications done by the
android team, is located on Google under subversion.

This link is  http://code.google.com/p/apps-for-android/ 

Regards
Anthoni






--



Network Unreachable (Socket.net Exception)

by himanshu jain » Mon, 08 Feb 2010 08:34:42 GMT


 Thanks Anthoni and Frank

@Anthoni and @Frank

I checked this code , actually i had already implemented in this way
instead of on  BOOT i used Alarm Manager that repeatedly wake up the
phone after 5 minutes and then i start my service.

But the problem is background service works fine for 15 minutes or
more and after sometimes it throws Socket.net Exception Network
Unreachable??. This is when i am trying to connect with my company
server for updates .







--



Network Unreachable (Socket.net Exception)

by himanshu jain » Mon, 08 Feb 2010 10:09:19 GMT


 @frank

Service does not crash completely , it consistently throwing
Socket.net Exception Netwrok unreachable after five minutes.
If phone is not always connected to network then what is the way of
implementing , i dont get this point . Yeah i am assuming phone is
connected with network and i should possibly connect to server on
stipulated time.

thanks




--



Network Unreachable (Socket.net Exception)

by prunicki » Mon, 08 Feb 2010 11:17:00 GMT


 I tried something similar back in Android 1.0/1.1 using only wifi.
What I found is that once the wifi connection was lost, the only way
to get it back was to fully wakeup the phone.

I think it may be different with the later versions of the SDK, but in
case it's not...

--



Network Unreachable (Socket.net Exception)

by himanshu jain » Mon, 08 Feb 2010 12:44:07 GMT


 @frank

I already tried in different network at home and at office , I have
been trying this on G1 at home i try on WIFI and at office at tried
when WIFI is OFF and i am using ip address not host name.

I am using Alarm manager which call service repeatedly after 5 minutes
so once it throws Exception(Network Unreachable). Alarm manager does
not stop by this exception it again start service on specified time
and then my service try to connect through HttpURLConnection it says
Network Unreachable.




--



Network Unreachable (Socket.net Exception)

by himanshu jain » Mon, 08 Feb 2010 12:49:37 GMT


 @prunicki

You application was connecting with internet repeatedly?? if yes did
you face this same issue and how did you work out that ?





--



Network Unreachable (Socket.net Exception)

by andrew_prunicki » Thu, 11 Feb 2010 09:53:14 GMT


 Sorry for the slow response.  I did not see your question until just
now.

I faced the same issue.  I had it connecting repeatedly over wifi
only.  What I learned was that the wifi radio was turned off when the
screensaver came on.  I went thru several attempts to get it to work.
I ended up getting a wake lock on the PowerManager, but this was very
expensive in terms of power usage.  I also locked the wifi with the
WifiManager.

This was back in Android 1.0/1.1, and I believe is completely
unnecessary now.  I noticed that Android 1.6 has the ability to keep
the wifi connection in the settings.  I imagine you can
programmatically do this as well - hopefully without acquiring a
wakelock.






--



Network Unreachable (Socket.net Exception)

by himanshu jain » Thu, 11 Feb 2010 16:23:36 GMT


 @andrew

Tell me one thing some people has wifi on most of them depend upon 2g
and 3g because of battery issue. So if wifi is not there i should
still expect this kind of error or issue???.
I mean i can not consistently poll to any website for news , if yes
how even when most does not have wifi ? is there any generic solution
to my problem.?









--



Network Unreachable (Socket.net Exception)

by himanshu jain » Thu, 11 Feb 2010 16:27:06 GMT


 @andrew

Tell me one thing some people have wifi on most of them depend upon 2g
and 3g because of battery issue. So if wifi is not there i should
still expect this kind of error or issue???.
I mean i can not consistently poll to any website for news , if yes
how even when most does not have wifi ? is there any generic solution
to my problem.?







--



Other Threads

1. Android Bug Reporting verbosity

Wow, this bug reporting thing is great.  I just noticed this new
feature the other day and it's very useful - I'd get helpful emails
from users saying "it don't work" and "it force closes when I do
<action>" with no clue of where the issue was in the code.

I'm wondering if there's currently any availability now or plans for
adding functionality to increase the level of verbosity of what shows
up in the stack traces- specifically, perhaps having the availability
to return customized messages via the Log function (i.e. Log.d(TAG,
"the value of x is " + x);)  That would be a great addition to an
already great feature.

Sorry if this question has been asked before - couldn't find anything
via search.

Thanks
Rob

-- 

2. How does Android implement copy-as-install and remove-as-uninstall?

I'm not certain that what you say is completely true. I've noticed
that manually putting an APK in /data/app makes it available, however
there are other things that happen during a correct installation which
this method bypasses. Specifically, I've noticed that if the APK
includes any native shared libraries, they won't get extracted using
this method (rendering an application that depends on this useless).
There may or may not be more install tasks which won't be performed
via copy.



> 

3. Brightness Android 2.2 vs Android 2.1

4. OOT : Thanks to Bos Nurfat

5. can i re-install an app without shutting down the emulator?

6. OOT: iseng2 weekend

7. isi sms forward sebagai email