vidstige / jadb

ADB Client in pure Java.
Apache License 2.0
640 stars 178 forks source link

Connect to tcp host "Connection refused" #110

Closed Bilb closed 6 years ago

Bilb commented 6 years ago

Hi, I am trying to useJadb to connect to a remote android board. I have enabled the tcpip mode and I can connect to it from my laptop using

adb connect :5555 connected to :5555

However, when I try to do the same using Jadb I get the following messages :

01-21 02:03:26.874 2056 2089 W System.err: java.net.ConnectException: Connection refused 01-21 02:03:26.875 2056 2089 W System.err: at java.net.PlainSocketImpl.socketConnect(Native Method) 01-21 02:03:26.875 2056 2089 W System.err: at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:334) 01-21 02:03:26.875 2056 2089 W System.err: at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:196) 01-21 02:03:26.875 2056 2089 W System.err: at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:178) 01-21 02:03:26.875 2056 2089 W System.err: at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:356) 01-21 02:03:26.875 2056 2089 W System.err: at java.net.Socket.connect(Socket.java:605) 01-21 02:03:26.875 2056 2089 W System.err: at java.net.Socket.connect(Socket.java:554) 01-21 02:03:26.876 2056 2089 W System.err: at java.net.Socket.<init>(Socket.java:431) 01-21 02:03:26.876 2056 2089 W System.err: at java.net.Socket.<init>(Socket.java:210) 01-21 02:03:26.876 2056 2089 W System.err: at se.vidstige.jadb.JadbConnection.createTransport(JadbConnection.java:27) 01-21 02:03:26.876 2056 2089 W System.err: at se.vidstige.jadb.JadbConnection.connectToTcpDevice(JadbConnection.java:41) 01-21 02:03:26.876 2056 2089 W System.err: at com.example.audric.jadbtest.MainActivity$1$1.run(MainActivity.java:44) 01-21 02:03:26.876 2056 2089 W System.err: at java.lang.Thread.run(Thread.java:761)

Can you help me resolve this issue ? I do not have socat on my board currently, but I do not thing it would help, as the connection is successful using the shell command.

Thanks, Audric

Bilb commented 6 years ago

Here is the source code associated with the code

` InetSocketAddress addr = new InetSocketAddress("ip",5555);

                    JadbConnection jadbConnection = new JadbConnection();
                    try {
                        jadbConnection.connectToTcpDevice(addr);
                    } catch (IOException e) {
                        e.printStackTrace();
                    } catch (JadbException e) {
                        e.printStackTrace();
                    } catch (ConnectionToRemoteDeviceException e) {
                        e.printStackTrace();
                    }`
SKART1 commented 6 years ago

JADB is adb client, not server.

You still need ADB server in the middle as far as I understand the question

< Android Device > <---> < ADB server > <--> < JADB >

Bilb commented 6 years ago

Ok, I think I got it.

Jadb tried to connect to adb server which does not run on my board, hence the connection refused.

Thanks

SKART1 commented 6 years ago

Actually adb server and jadb may run on different hosts (it is possible with some hacks)