Question

While calling wcf ksoap2 from android.

htp.call(SOAP_ACTION, soapEnvelop);

I am getting this exception.

java.net.ConnectException: failed to connect to /10.0.2.2 (port 52442) after 20000ms: connect failed: ENETUNREACH (Network is unreachable)

My code was working fine till last night but now its not.

Thanks in advance

Was it helpful?

Solution

It's obvious it's not any router-firewall related problem as you are under the same net, so there are only three possibilities:

  1. There's nothing listening on that port on that IP
  2. There's a local firewall on that machine that is blocking that connection attempt
  3. You are not using WIFI so you're not under the same net.

Can you open that URL from your browser in your computer manually? If yes, I'd suggest using some debugging tool to trace TCP packets (I don't know either what kind of operating system you use on the destination machine; if it's some linux distribution, tcpdump might help).

All that assuming you have the android.permission.INTERNET permission in your AndroidManifest.xml file.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top