1

I am trying to trace a request originating from android and send some data to serversocket at each hop. I am using below code to execute client and send data to ServerSocket at each hop (tomcats having servlet projects) and they are able to send and connect.

However when I try to use same below code in android app running on emulator on same machine. It throws me timeout error.

InetSocketAddress hostAddress = new InetSocketAddress(hostAdress,
                    SocketServerPORT);
            SocketChannel client = SocketChannel.open(hostAddress);

after open execution gives me

java.net.ConnectException: failed to connect to /192.168.0.102 (port 8090): connect failed: ETIMEDOUT (Connection timed out)
01-24 13:25:58.140 3382-3424/app W/System.err:     at libcore.io.IoBridge.connect(IoBridge.java:124)
01-24 13:25:58.140 3382-3424/app W/System.err:     at libcore.io.IoBridge.connect(IoBridge.java:110)
01-24 13:25:58.140 3382-3424/app W/System.err:  .....

what could possibly be wrong here?

my app has

<uses-permission android:name="android.permission.INTERNET" />.

I have also used

Socket socket = new Socket(hostaddress,port)

It throws same exception.

2
  • 1
    This is a network connectivity problem, not a programming problem.
    – user207421
    Jan 25, 2016 at 11:24
  • looks like so .I am not sure but strongly suspect that android emulator requires some tweaking (port forwarding or something ). I have made temporary arrangement with one more intermediate tomcat to acheive conectivity between android and serversocket. will come back post here when I succeed.
    – teksan
    Jan 25, 2016 at 17:57

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.