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.

teksan
  • 142
  • 13
  • 1
    This is a network connectivity problem, not a programming problem. – user207421 Jan 25 '16 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 '16 at 17:57

0 Answers0