Skip to content Skip to sidebar Skip to footer

Invoke Wcf Web Service Using Ksoap2 On Android App Failed With The Following Error Java.net.SocketTimeoutException: Connection Timeout

I'm new to android and I wanted to call wcf web service. I have found ksoap2 library and stated to apply the examples I found.The app failed with the following error message: java

Solution 1:

Connection timeouts occur when:

  • The IP address for the requested server is successfully found
  • Connection establishment packets are dispatched to the IP address
  • The destination address deliberately ignores or does not receive them

Similar to connection timeout is Connection Refused, but in this case the destination system is actually sending packets back saying "go away, there is no service running on the port you are trying to connect to"

Connection timed out is an expected behavior in a network environment. It's even more expected in a mobile environment, where network connections can be unreliable. It means that the server failed to respond for a certain number of seconds.


Solution 2:

You cannot access your local machine by using localhost or 127.0.0.1 from android. You need to use 10.0.2.2 to access yout local machine.

Actually I didn't get the android to connect to a WCF service correctly...


Solution 3:

Although this may be a little late, this is what fixed it for me:

HttpTransportSE androidHttpTransport = new HttpTransportSE(URL,60000);

Notice the second parameter, which is the timeout value.

I must admit tough, that i do not know the scale to go with this value, but I think this is measured in milliseconds.


Solution 4:

add this :

StrictMode.ThreadPolicy policy = new   StrictMode.ThreadPolicy.Builder().permitAll().build(); 
        StrictMode.setThreadPolicy(policy);

Post a Comment for "Invoke Wcf Web Service Using Ksoap2 On Android App Failed With The Following Error Java.net.SocketTimeoutException: Connection Timeout"