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. How to transfer data with a successful bluetooth connection.?

I want to implement an application which can successfully transfer a
file from my android eclair device to any other bluetooth device.

After device discovery and pairing, I'm trying to connect with a
remote bluetooth device using:

BluetoothSocket socket =
mbluetoothdevice.createrfcommsockettoservicerecord(uuid);
I'm explicitly specifying the uuid for Object push like,
UUID uuid = UUID.fromstring("00001105-0000-1000-8000-00805F9B34FB");
once i try, socket.connect();
I receive BluetoothSocket.ACL_CONNECTED intent, and two or more
android.bleutooth.extra.UUID intents,
later the connection is shutting off immediately.
Even I'm trying to use outputstream.write(int); to transfer the data,
but it's not working well for me.

Please if anybody know the solutions, kindly help me out,
mail me at narendraprabh...@gmail.com or post back here please...

-- 

2. is AppWidgetProvider informed if adding a widget fails due to not enough space on homescreen.

My app has a 1*4 icon size widget.
When a user tries to add a widget I provide with a configuration
screen. and some data is collected - it is verified by the server - it
is added to the local DB with appWidgetID as the key - all is good.

when user hits save, if there is not enough space, he is given a
polite toast - "No more room on this home screen".

Now my problem is that the application is not informed of this.
Application still assumes the widget was created and sits back and
wait for the broadcast to update the widget after certain amount of
time.

Can anyone tell me if i can find out via a broadcast or a call back or
any method possible to determine if the widget was not successfully
created, so that i can mark that record in my DB as deleted.

Or better if i can know the space available beforehand via some magic
ninja code.

my whole application design is disturbed because of this problem.
please help.

-- 

3. What use for simple drawing on screen

4. Adding database to application

5. Is glPointSizePointerOES that takes an offset param missing from GL API?

6. help,how to set imageview's alpha,not imageview' ImageResource's alpha

7. developing on a physical device