termux-packages icon indicating copy to clipboard operation
termux-packages copied to clipboard

[Bug]: android-tools (adb) cannot connect to daemon

Open ghost opened this issue 4 years ago • 54 comments

Problem description

when i trying to connect to adb i'm getting this error

~ ❯ adb pair localhost:42062
Enter pairing code: 269850
* daemon not running; starting now at tcp:5037
* daemon started successfully
* daemon still not running
error: cannot connect to daemon at tcp:5037: Not a data message

Screenshot-20211107-182144-Termux

this error has never happened to me before

What steps will reproduce the bug?

connecting with adb via wireless

What is the expected behavior?

No response

System information

termux-info:

Application version:
0.117
Packages CPU architecture:
aarch64
Subscribed repositories:
# sources.list
deb https://termux.librehat.com/apt/termux-main/ stable main
# science-repo (sources.list.d/science.list)
deb https://packages.termux.org/apt/termux-science science stable
# game-repo (sources.list.d/game.list)
deb https://packages.termux.org/apt/termux-games games stable
# x11-repo (sources.list.d/x11.list)
deb https://packages.termux.org/apt/termux-x11 x11 main
Updatable packages:
All packages up to date
Android version:
11
Kernel build information:
Linux localhost 4.4.177-21848546 #1 SMP PREEMPT Tue Jun 8 18:55:47 KST 2021 aarch64 Android
Device manufacturer:
samsung
Device model:
SM-A205F

ghost avatar Nov 07 '21 16:11 ghost

@ian4hu, is it working for you?

finagolfin avatar Nov 08 '21 09:11 finagolfin

@ELWAER-M it (31.0.3) works on my device like bellow.

~ $ pkg install android-tools
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following NEW packages will be installed:
  android-tools
0 upgraded, 1 newly installed, 0 to remove and 17 not upgraded.
Need to get 0 B/1158 kB of archives.
After this operation, 4276 kB of additional disk space will be used.
Selecting previously unselected package android-tools.
(Reading database ... 14993 files and directories currently installed.)
Preparing to unpack .../android-tools_31.0.3_aarch64.deb ...
Unpacking android-tools (31.0.3) ...
Setting up android-tools (31.0.3) ...
~ $ adb version
Android Debug Bridge version 1.0.41
Version 31.0.3-android-tools
Installed as /data/data/com.termux/files/usr/bin/adb
~ $ adb devices
List of devices attached

~ $ adb pair localhost:41621
Enter pairing code: XXXXXX
Successfully paired to localhost:41621 [guid=adb-XXXXX-FTsFiT]
~ $ adb devices -l
List of devices attached

~ $ adb connect localhost:41615
connected to localhost:41615
~ $ adb devices
List of devices attached
localhost:41615 device

~ $

I am not sure what your android-tools package version.

ian4hu avatar Nov 08 '21 14:11 ian4hu

@ELWAER-M In your screenshot I see a warning about * daemon still not running error: cannot connect to daemon at tcp:5037: Not a data message , It is said that your adb server daemon is not started and it dose not listen on port 5037.

You should find out is there any other app is listen on 5037. or the adb-server is started. The corrent adb server should like bellow

~ $ ps aux | grep adb | grep server
u0_a244   9149  0.0  0.0 2236892 8396 ?        S<sl  1970   0:00 adb -L tcp:5037 fork-server server --reply-fd 4
~ $

you can try to start adb server manually by adb kill-server && adb start-server .

ian4hu avatar Nov 08 '21 14:11 ian4hu

@ian4hu

~ ❯ adb version
Android Debug Bridge version 1.0.41
Version 31.0.3-android-tools
Installed as /data/data/com.termux/files/usr/bin/adb
~ ❯ adb devices
* daemon not running; starting now at tcp:5037                         * daemon started successfully
List of devices attached
* daemon still not running
error: cannot connect to daemon at tcp:5037: Not a data message        
~ ❯ ps aux
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
u0_a1326 22437  7.7  4.0 6096580 113220 ?      S<l   1970   0:56 com.teu0_a1326 23186  0.1  0.1 2134008 3744 pts/0    S<s   1970   0:00 /data/
u0_a1326 25614  0.1  0.1 2201784 4408 ?        S<sl  1970   0:00 adb -L
u0_a1326 25639  0.0  0.0 2132076 2096 pts/0    R<+   1970   0:00 ps aux
~ ❯ kill 25614
~ ❯ ps aux
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
u0_a1326 22437  7.9  4.1 6096648 115636 ?      S<l   1970   0:58 com.te
u0_a1326 23186  0.1  0.1 2134008 3744 pts/0    S<s   1970   0:00 /data/u0_a1326 25675  1.0  0.0 2132076 2096 pts/0    R<+   1970   0:00 ps aux
~ ❯ adb start-server
* daemon not running; starting now at tcp:5037
* daemon started successfully
~ ❯ adb devices
* daemon not running; starting now at tcp:5037
ADB server didn't ACK
Full server startup log: /data/data/com.termux/files/usr/tmp/adb.11326.log
Server had pid: 25719
--- adb starting (pid 25719) ---
adb I 11-08 19:29:48 25719 25719 main.cpp:63] Android Debug Bridge version 1.0.41
adb I 11-08 19:29:48 25719 25719 main.cpp:63] Version 31.0.3-android-tools
adb I 11-08 19:29:48 25719 25719 main.cpp:63] Installed as /data/data/com.termux/files/usr/bin/adb
adb I 11-08 19:29:48 25719 25719 main.cpp:63]
adb F 11-08 19:29:49 25719 25719 main.cpp:155] could not install *smartsocket* listener: Address already in use

* failed to start daemon
adb: failed to check server version: cannot connect to daemon

ghost avatar Nov 08 '21 17:11 ghost

@ELWAER-M thanks for your details. Could you please attach the full '/data/data/com.termux/files/usr/tmp/adb.11326.log'

ian4hu avatar Nov 08 '21 23:11 ian4hu

--- adb starting (pid 2457) ---
adb I 11-09 03:34:14  2457  2457 main.cpp:63] Android Debug Bridge version 1.0.41
adb I 11-09 03:34:14  2457  2457 main.cpp:63] Version 31.0.3-android-tools
adb I 11-09 03:34:14  2457  2457 main.cpp:63] Installed as /data/data/com.termux/files/usr/bin/adb
adb I 11-09 03:34:14  2457  2457 main.cpp:63] 
adb I 11-09 03:34:14  2457  2457 auth.cpp:417] adb_auth_init...
adb I 11-09 03:34:14  2457  2457 auth.cpp:152] loaded new key from '/data/data/com.termux/files/home/.android/adbkey' with fingerprint 69B47B078799BD12CC4321E54721ED82EB61087D8B1407269CA74311DD4332FA
adb I 11-09 03:34:14  2457  2457 auth.cpp:392] adb_auth_inotify_init...
--- adb starting (pid 2563) ---
adb I 11-09 03:34:24  2563  2563 main.cpp:63] Android Debug Bridge version 1.0.41
adb I 11-09 03:34:24  2563  2563 main.cpp:63] Version 31.0.3-android-tools
adb I 11-09 03:34:24  2563  2563 main.cpp:63] Installed as /data/data/com.termux/files/usr/bin/adb
adb I 11-09 03:34:24  2563  2563 main.cpp:63] 
adb F 11-09 03:34:25  2563  2563 main.cpp:155] could not install *smartsocket* listener: Address already in use

ghost avatar Nov 09 '21 01:11 ghost

@ELWAER-M It seems the adb server is stucked in start up smartsocket. Would you mind execute the follow steps and attach the log ? The follow steps will turn on adb trace and set adb server logging to /data/data/com.termux/files/home/adb.log, You can get the adb server trace log by cat /data/data/com.termux/files/home/adb.log;

~ $ export ANDROID_ADB_LOG_PATH=/data/data/com.termux/files/home/adb.log
~ $ export ADB_TRACE=all
~ $ adb kill-server
adb D 11-09 12:25:08  3448  3448 adb_trace.cpp:187] Android Debug Bridge version 1.0.41
adb D 11-09 12:25:08  3448  3448 adb_trace.cpp:187] Version 31.0.3-android-tools
adb D 11-09 12:25:08  3448  3448 adb_trace.cpp:187] Installed as /data/data/com.termux/files/usr/bin/adb
adb D 11-09 12:25:08  3448  3448 adb_trace.cpp:187]
adb D 11-09 12:25:08  3448  3448 adb_client.cpp:194] adb_kill_server
adb D 11-09 12:25:08  3448  3448 adb_io.cpp:107] writex: fd=3 len=13 30303039686f73743a6b696c6c 0009host:kill
adb D 11-09 12:25:08  3448  3448 adb_io.cpp:81] readx: fd=3 wanted=4
adb D 11-09 12:25:08  3448  3448 adb_io.cpp:97] readx: fd=3 wanted=4 got=4 4f4b4159 OKAY
~ $ adb start-server
adb D 11-09 12:25:14  3451  3451 adb_trace.cpp:187] Android Debug Bridge version 1.0.41
adb D 11-09 12:25:14  3451  3451 adb_trace.cpp:187] Version 31.0.3-android-tools
adb D 11-09 12:25:14  3451  3451 adb_trace.cpp:187] Installed as /data/data/com.termux/files/usr/bin/adb
adb D 11-09 12:25:14  3451  3451 adb_trace.cpp:187]
adb D 11-09 12:25:14  3451  3451 adb_client.cpp:346] adb_connect: service: host:start-server
adb D 11-09 12:25:14  3451  3451 adb_client.cpp:155] _adb_connect: host:version
* daemon not running; starting now at tcp:5037
adb D 11-09 12:25:14  3452  3452 adb_trace.cpp:187] Android Debug Bridge version 1.0.41
adb D 11-09 12:25:14  3452  3452 adb_trace.cpp:187] Version 31.0.3-android-tools
adb D 11-09 12:25:14  3452  3452 adb_trace.cpp:187] Installed as /data/data/com.termux/files/usr/bin/adb
adb D 11-09 12:25:14  3452  3452 adb_trace.cpp:187]
* daemon started successfully
~ $ cat $ANDROID_ADB_LOG_PATH
--- adb starting (pid 3395) ---
adb I 11-09 12:22:57  3395  3395 main.cpp:63] Android Debug Bridge version 1.0.41
adb I 11-09 12:22:57  3395  3395 main.cpp:63] Version 31.0.3-android-tools
adb I 11-09 12:22:57  3395  3395 main.cpp:63] Installed as /data/data/com.termux/files/usr/bin/adb
adb I 11-09 12:22:57  3395  3395 main.cpp:63]
adb D 11-09 12:22:57  3395  3395 transport.cpp:844] socketpair: (3,5)
adb D 11-09 12:22:57  3395  3395 transport_local.cpp:233] transport: local client init
adb I 11-09 12:22:57  3395  3395 auth.cpp:417] adb_auth_init...
adb D 11-09 12:22:57  3395  3398 transport_local.cpp:191] transport: client_socket_thread() starting
adb D 11-09 12:22:57  3395  3397 usb_linux.cpp:609] Created device thread
adb I 11-09 12:22:57  3395  3395 auth.cpp:152] loaded new key from '/data/data/com.termux/files/home/.android/adbkey' with fingerprint C9DB65937F17EC722F0AE48139E7D81B046AE9B74362BD81CCB26761C2EA4159
adb I 11-09 12:22:57  3395  3395 auth.cpp:392] adb_auth_inotify_init...
adb D 11-09 12:22:57  3395  3395 main.cpp:230] Event loop starting
adb D 11-09 12:22:57  3395  3395 fdevent_epoll.cpp:174] (fdevent 0: fd 7 R) got events 0x1
adb D 11-09 12:25:08  3395  3395 fdevent_epoll.cpp:174] (fdevent 2: fd 9 R) got events 0x1
adb D 11-09 12:25:08  3395  3395 sockets.cpp:399] LS(1): created (fd=4)
adb D 11-09 12:25:08  3395  3395 sockets.cpp:903] Connecting to smart socket
adb D 11-09 12:25:08  3395  3395 sockets.cpp:891] Creating smart socket
adb D 11-09 12:25:08  3395  3395 sockets.cpp:898] SS(0)
adb D 11-09 12:25:08  3395  3395 fdevent_epoll.cpp:174] (fdevent 4: fd 4 R) got events 0x1
adb D 11-09 12:25:08  3395  3395 sockets.cpp:353] LS(1): event_func(fd=4(==4), ev=0001)
adb D 11-09 12:25:08  3395  3395 sockets.cpp:164] LS(1): post adb_read(fd=4,...) r=13 (errno=0) avail=1048576
adb D 11-09 12:25:08  3395  3395 sockets.cpp:164] LS(1): post adb_read(fd=4,...) r=-1 (errno=11) avail=1048563
adb D 11-09 12:25:08  3395  3395 sockets.cpp:180] LS(1): fd=4 post avail loop. r=-1 is_eof=0 forced_eof=0
adb D 11-09 12:25:08  3395  3395 sockets.cpp:722] SS(0): enqueue 13
adb D 11-09 12:25:08  3395  3395 sockets.cpp:742] SS(0): len is 9
adb D 11-09 12:25:08  3395  3395 sockets.cpp:751] SS(0): 'host:kill'
adb server killed by remote request

ian4hu avatar Nov 09 '21 04:11 ian4hu

@ian4hu

~ ❯ export ANDROID_ADB_LOG_PATH=/data/data/com.termux/files/home/adb.log
~ ❯ export ADB_TRACE=all
~ ❯ adb kill-server
adb D 11-09 13:09:54  1177  1177 adb_trace.cpp:187] Android Debug Bridge version 1.0.41
adb D 11-09 13:09:54  1177  1177 adb_trace.cpp:187] Version 31.0.3-android-tools
adb D 11-09 13:09:54  1177  1177 adb_trace.cpp:187] Installed as /data/data/com.termux/files/usr/bin/adb
adb D 11-09 13:09:54  1177  1177 adb_trace.cpp:187]
adb D 11-09 13:09:54  1177  1177 adb_client.cpp:194] adb_kill_server
cannot connect to daemon at tcp:5037: Not a data message
~ ❯ adb start-server
adb D 11-09 13:10:06  1243  1243 adb_trace.cpp:187] Android Debug Bridge version 1.0.41
adb D 11-09 13:10:06  1243  1243 adb_trace.cpp:187] Version 31.0.3-android-tools
adb D 11-09 13:10:06  1243  1243 adb_trace.cpp:187] Installed as /data/data/com.termux/files/usr/bin/adb
adb D 11-09 13:10:06  1243  1243 adb_trace.cpp:187]
adb D 11-09 13:10:06  1243  1243 adb_client.cpp:346] adb_connect: service: host:start-server
adb D 11-09 13:10:06  1243  1243 adb_client.cpp:155] _adb_connect: host:version
* daemon not running; starting now at tcp:5037
adb D 11-09 13:10:06  1244  1244 adb_trace.cpp:187] Android Debug Bridge version 1.0.41
adb D 11-09 13:10:06  1244  1244 adb_trace.cpp:187] Version 31.0.3-android-tools
adb D 11-09 13:10:06  1244  1244 adb_trace.cpp:187] Installed as /data/data/com.termux/files/usr/bin/adb
adb D 11-09 13:10:06  1244  1244 adb_trace.cpp:187]
ADB server didn't ACK
Full server startup log: /data/data/com.termux/files/home/adb.log
Server had pid: 1244
--- adb starting (pid 1244) ---
adb I 11-09 13:10:06  1244  1244 main.cpp:63] Android Debug Bridge version 1.0.41
adb I 11-09 13:10:06  1244  1244 main.cpp:63] Version 31.0.3-android-tools
adb I 11-09 13:10:06  1244  1244 main.cpp:63] Installed as /data/data/com.termux/files/usr/bin/adb
adb I 11-09 13:10:06  1244  1244 main.cpp:63]
adb D 11-09 13:10:06  1244  1244 transport.cpp:844] socketpair: (3,5)
adb D 11-09 13:10:06  1244  1244 transport_local.cpp:233] transport: local client init
adb D 11-09 13:10:06  1244  1246 usb_linux.cpp:609] Created device thread
adb D 11-09 13:10:06  1244  1247 transport_local.cpp:191] transport: client_socket_thread() starting
adb F 11-09 13:10:06  1244  1244 main.cpp:155] could not install *smartsocket* listener: Address already in use

* failed to start daemon
error: cannot connect to daemon
~ ❯ cat $ANDROID_ADB_LOG_PATH
--- adb starting (pid 430) ---
adb I 11-09 13:07:56   430   430 main.cpp:63] Android Debug Bridge version 1.0.41
adb I 11-09 13:07:56   430   430 main.cpp:63] Version 31.0.3-android-tools
adb I 11-09 13:07:56   430   430 main.cpp:63] Installed as /data/data/com.termux/files/usr/bin/adb
adb I 11-09 13:07:56   430   430 main.cpp:63]
adb D 11-09 13:07:56   430   430 transport.cpp:844] socketpair: (3,5)
adb D 11-09 13:07:56   430   430 transport_local.cpp:233] transport: local client init
adb I 11-09 13:07:56   430   430 auth.cpp:417] adb_auth_init...
adb D 11-09 13:07:56   430   433 transport_local.cpp:191] transport: client_socket_thread() starting
adb D 11-09 13:07:56   430   432 usb_linux.cpp:609] Created device thread
adb I 11-09 13:07:56   430   430 auth.cpp:152] loaded new key from '/data/data/com.termux/files/home/.android/adbkey' with fingerprint 69B47B078799BD12CC4321E54721ED82EB61087D8B1407269CA74311DD4332FA
adb I 11-09 13:07:56   430   430 auth.cpp:392] adb_auth_inotify_init...
adb D 11-09 13:07:56   430   430 main.cpp:230] Event loop starting
adb D 11-09 13:07:56   430   430 fdevent_epoll.cpp:174] (fdevent 0: fd 7 R) got events 0x1
--- adb starting (pid 1244) ---
adb I 11-09 13:10:06  1244  1244 main.cpp:63] Android Debug Bridge version 1.0.41
adb I 11-09 13:10:06  1244  1244 main.cpp:63] Version 31.0.3-android-tools
adb I 11-09 13:10:06  1244  1244 main.cpp:63] Installed as /data/data/com.termux/files/usr/bin/adb
adb I 11-09 13:10:06  1244  1244 main.cpp:63]
adb D 11-09 13:10:06  1244  1244 transport.cpp:844] socketpair: (3,5)
adb D 11-09 13:10:06  1244  1244 transport_local.cpp:233] transport: local client init
adb D 11-09 13:10:06  1244  1246 usb_linux.cpp:609] Created device thread
adb D 11-09 13:10:06  1244  1247 transport_local.cpp:191] transport: client_socket_thread() starting
adb F 11-09 13:10:06  1244  1244 main.cpp:155] could not install *smartsocket* listener: Address already in use
~ ❯

ghost avatar Nov 09 '21 11:11 ghost

@ELWAER-M

The error is from here.

// If we told a previous adb server to quit because of version mismatch, we can get to this // point before it's finished exiting. Retry for a while to give it some time. Don't actually // accept any connections until adb_wait_for_device_initialization finishes below.

Considering that EADDRINUSE (Address already in use) is being thrown, that means address/port is already being used by some existing adb server. Do you have some other apps that may start a server? There are a few adb related apps and their server processes wouldn't show in ps output in termux since uid will be different. Try running adb shell "ps -ef | grep adb" from pc and see if some processes show. I don't have a physical android 12 device so haven't tested the command. Moreover, you may not be able to connect from pc if something has already connected to adb host daemon on your device.

Otherwise try restarting the device and see if that helps.

agnostic-apollo avatar Nov 09 '21 23:11 agnostic-apollo

i don't have any server running or anything like that and i saw a guy on discord have the same problem Screenshot-20211110-041735 and looks like he using a samsung phone too so this problem happening just in samsung phones maybe

ghost avatar Nov 10 '21 02:11 ghost

i don't have any server running or anything like that

Just to confirm, you checked this from pc, not from termux, right? Termux user cannot access processes started by other apps.

so this problem happening just in samsung phones maybe

Have you previously used android-tools on your phone, like older version. Did you receive an android OS upgrade recently from Samsung?

Maybe try an alternative port for adb server. The adb command has the -P global option that can be used for custom port for server. It needs to be passed to every adb command.

So try adb -P 5038 start-server, adb -P 5038 pair localhost:<port>, adb -P 5038 connect localhost and adb -P 5038 shell. Or try an even higher port, like 50370. Maybe there is some port restriction, just a guess.

agnostic-apollo avatar Nov 10 '21 02:11 agnostic-apollo

Just to confirm, you checked this from pc, not from termux, right?

i have not checking it from a pc sorry, i dont have access to one

Have you previously used android-tools on your phone, like older version. Did you receive an android OS upgrade recently from Samsung?

the older version of android-tools was working fine for me but after i updated it this problem come out

Maybe try an alternative port for adb server. The adb command has the -P global option that can be used for custom port for server. It needs to be passed to every adb command.

~ ❯ adb -P 5038 start-server
* daemon not running; starting now at tcp:5038
* daemon started successfully
~ ❯ adb -P 5038 pair localhost:39631
Enter pairing code: 405865
* daemon not running; starting now at tcp:5038
ADB server didn't ACK
Full server startup log: /data/data/com.termux/files/usr/tmp/adb.11326.log
Server had pid: 18450
--- adb starting (pid 18450) ---
adb I 11-10 04:53:37 18450 18450 main.cpp:63] Android Debug Bridge version 1.0.41
adb I 11-10 04:53:37 18450 18450 main.cpp:63] Version 31.0.3-android-tools
adb I 11-10 04:53:37 18450 18450 main.cpp:63] Installed as /data/data/com.termux/files/usr/bin/adb
adb I 11-10 04:53:37 18450 18450 main.cpp:63]
adb F 11-10 04:53:38 18450 18450 main.cpp:155] could not install *smartsocket* listener: Address already in use

* failed to start daemon
error: cannot connect to daemon

ghost avatar Nov 10 '21 03:11 ghost

I guess you are back to https://github.com/termux/termux-packages/issues/7946#issuecomment-963395206. Does ps show the server running after start-server command?

Did you try restarting phone?

agnostic-apollo avatar Nov 10 '21 03:11 agnostic-apollo

Did you try restarting phone?

yes i did

ghost avatar Nov 10 '21 03:11 ghost

@ELWAER-M Try a higher port number.

So try adb -P 5038 start-server, adb -P 5038 pair localhost:, adb -P 5038 connect localhost and adb -P 5038 shell. Or try an even higher port, like 50370. Maybe there is some port restriction, just a guess.

Like 50370

ian4hu avatar Nov 10 '21 03:11 ian4hu

@ian4hu i tried with different ports it's still the same

~ ❯ adb -P 50370 start-server
* daemon not running; starting now at tcp:50370
* daemon started successfully
~ ❯ adb -P 50370 pair localhost:45684
Enter pairing code: 465936
* daemon not running; starting now at tcp:50370
ADB server didn't ACK
Full server startup log: /data/data/com.termux/files/usr/tmp/adb.11326.log
Server had pid: 31556
--- adb starting (pid 31556) ---
adb I 11-10 05:24:18 31556 31556 main.cpp:63] Android Debug Bridge version 1.0.41
adb I 11-10 05:24:18 31556 31556 main.cpp:63] Version 31.0.3-android-tools
adb I 11-10 05:24:18 31556 31556 main.cpp:63] Installed as /data/data/com.termux/files/usr/bin/adb
adb I 11-10 05:24:18 31556 31556 main.cpp:63]
adb F 11-10 05:24:19 31556 31556 main.cpp:155] could not install *smartsocket* listener: Address already in use

* failed to start daemon
error: cannot connect to daemon

ghost avatar Nov 10 '21 03:11 ghost

Does ps show the server running after start-server command?

Try to answer all asked questions instead of us repeating them.

agnostic-apollo avatar Nov 10 '21 03:11 agnostic-apollo

@agnostic-apollo

~ ❯ adb start-server
* daemon not running; starting now at tcp:5037
* daemon started successfully
~ ❯ ps
  PID TTY          TIME CMD
 7683 pts/0    00:00:00 bash
 7842 pts/0    00:00:00 ps
~ ❯ ps aux
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
u0_a1326  6181  5.1  4.4 5790460 124000 ?      S<l   1970   0:06 com.termux
u0_a1326  7683  0.5  0.1 2134008 3948 pts/0    S<s   1970   0:00 /data/data/com.termux/files/usr/bin/bash -l
u0_a1326  7802  0.3  0.1 2201784 4376 ?        S<sl  1970   0:00 adb -L tcp:5037 fork-server server --reply-fd 4
u0_a1326  7909  1.0  0.0 2132076 2088 pts/0    R<+   1970   0:00 ps aux

ghost avatar Nov 10 '21 03:11 ghost

So if server is successfully started by adb start-server, then why does it say daemon not running; starting now at tcp:* when adb pair is run. 🤔

agnostic-apollo avatar Nov 10 '21 03:11 agnostic-apollo

@ELWAER-M Post output for strace adb pair localhost:<port>. Maybe that shows something.

agnostic-apollo avatar Nov 10 '21 03:11 agnostic-apollo

Post output for strace adb pair localhost:. Maybe that shows something.

the output is too long my browser keeps crashing when i pasting it...

ghost avatar Nov 10 '21 04:11 ghost

Redirect command or store output in a file and upload that.

agnostic-apollo avatar Nov 10 '21 04:11 agnostic-apollo

log.txt

ghost avatar Nov 10 '21 04:11 ghost

That is not full output. Enter pairing code and press enter after it says

write(1, "Enter pairing code: ", 20Enter pairing code: )    = 20
fstat(0, {st_mode=S_IFCHR|0600, st_rdev=makedev(0x88, 0), ...}) = 0
ioctl(0, TCGETS, {B38400 opost isig icanon echo ...}) = 0
read(0, 0x7e8162a400, 1024)             = ? ERESTARTSYS (To be restarted if SA_RESTART is set)
--- SIGWINCH {si_signo=SIGWINCH, si_code=SI_KERNEL} ---
read(0,

agnostic-apollo avatar Nov 10 '21 04:11 agnostic-apollo

log.txt

ghost avatar Nov 10 '21 04:11 ghost

I got same errors. I am also using a Samsung phone. And both android-tools and termux are up-to-date.

goINTo425 avatar Nov 24 '21 12:11 goINTo425

Same issue was found on my Samsung S21 (android 11, SM-G9910). My Pixel 4a (android 12) does not have any issue.

knyipab avatar Nov 26 '21 01:11 knyipab

It seems this bug is device-associated/rom-associated. I dont have a Samsung android phone, it would be difficult for me to get the root cause.

ian4hu avatar Nov 26 '21 01:11 ian4hu

I'm having the same issue on a Samsung S21. What I'm seeing is the following:

When starting the adb server for the first time, everyting is fine:

adb D 12-11 11:52:50 11446 11446 adb_trace.cpp:187] Android Debug Bridge version 1.0.41
adb D 12-11 11:52:50 11446 11446 adb_trace.cpp:187] Version 31.0.3-android-tools
adb D 12-11 11:52:50 11446 11446 adb_trace.cpp:187] Installed as /data/data/com.termux/files/usr/bin/adb
adb D 12-11 11:52:50 11446 11446 adb_trace.cpp:187] 
adb D 12-11 11:52:50 11446 11446 adb_client.cpp:346] adb_connect: service: host:start-server
adb D 12-11 11:52:50 11446 11446 adb_client.cpp:155] _adb_connect: host:version
* daemon not running; starting now at tcp:5037
adb D 12-11 11:52:50 11447 11447 adb_trace.cpp:187] Android Debug Bridge version 1.0.41
adb D 12-11 11:52:50 11447 11447 adb_trace.cpp:187] Version 31.0.3-android-tools
adb D 12-11 11:52:50 11447 11447 adb_trace.cpp:187] Installed as /data/data/com.termux/files/usr/bin/adb
adb D 12-11 11:52:50 11447 11447 adb_trace.cpp:187] 
* daemon started successfully

I can then see that the server is running

u0_a6         7918     1 0 11:38:06 ?     00:00:00 adb -L tcp:5037 fork-server server --reply-fd 4```

I can also see that the server is listeing on 127.0.0.1:5037
```> netstat -tulpn | grep LISTEN
tcp        0      0 127.0.0.1:5037          0.0.0.0:*               LISTEN      -

When I now however run a adb command, adb tries to connect to the server and fails. Then tries to start the server again, which fails beacuse the server is arleady running:

adb D 12-11 11:53:03 11503 11503 adb_trace.cpp:187] Android Debug Bridge version 1.0.41
adb D 12-11 11:53:03 11503 11503 adb_trace.cpp:187] Version 31.0.3-android-tools
adb D 12-11 11:53:03 11503 11503 adb_trace.cpp:187] Installed as /data/data/com.termux/files/usr/bin/adb
adb D 12-11 11:53:03 11503 11503 adb_trace.cpp:187] 
adb D 12-11 11:53:03 11503 11503 adb_client.cpp:155] _adb_connect: host:version
* daemon not running; starting now at tcp:5037
adb D 12-11 11:53:03 11504 11504 adb_trace.cpp:187] Android Debug Bridge version 1.0.41
adb D 12-11 11:53:03 11504 11504 adb_trace.cpp:187] Version 31.0.3-android-tools
adb D 12-11 11:53:03 11504 11504 adb_trace.cpp:187] Installed as /data/data/com.termux/files/usr/bin/adb
adb D 12-11 11:53:03 11504 11504 adb_trace.cpp:187] 
ADB server didn't ACK
Full server startup log: /data/data/com.termux/files/usr/tmp/adb.10006.log
Server had pid: 11504
--- adb starting (pid 11504) ---
adb I 12-11 11:53:03 11504 11504 main.cpp:63] Android Debug Bridge version 1.0.41
adb I 12-11 11:53:03 11504 11504 main.cpp:63] Version 31.0.3-android-tools
adb I 12-11 11:53:03 11504 11504 main.cpp:63] Installed as /data/data/com.termux/files/usr/bin/adb
adb I 12-11 11:53:03 11504 11504 main.cpp:63] 
adb D 12-11 11:53:03 11504 11504 transport.cpp:844] socketpair: (3,5)
adb D 12-11 11:53:03 11504 11504 transport_local.cpp:233] transport: local client init
adb D 12-11 11:53:03 11504 11506 usb_linux.cpp:609] Created device thread
adb D 12-11 11:53:03 11504 11507 transport_local.cpp:191] transport: client_socket_thread() starting
adb F 12-11 11:53:04 11504 11504 main.cpp:155] could not install *smartsocket* listener: Address already in use

* failed to start daemon
adb: failed to check server version: cannot connect to daemon

I quickly checked with telnet if the server is actually listening on localhost:5037, and it is. So for whatever reason adb cant connect to the tcp port on Samsung phones.

I found a workaround, you can tell adb to use a file as socket instead

>export ADB_SERVER_SOCKET=localfilesystem:$(pwd)/adb_socket
>adb start-server
* daemon started successfully
>adb devices
List of devices attached

Ingrater avatar Dec 11 '21 12:12 Ingrater

This is strace output from a working android 11 device attached. Line 1036

rt_sigaction(SIGPIPE, {sa_handler=SIG_IGN, sa_mask=[], sa_flags=SA_RESTART}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
socket(AF_INET, SOCK_STREAM, IPPROTO_IP) = 3
bind(3, {sa_family=AF_INET, sin_port=htons(0), sin_addr=inet_addr("127.0.0.1")}, 16) = 0
getsockopt(3, SOL_SOCKET, SO_DOMAIN, [2], [4]) = 0
futex(0x7a43aec2f0, FUTEX_WAKE_PRIVATE, 2147483647) = 0
socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC, 0) = 4
connect(4, {sa_family=AF_UNIX, sun_path="/dev/socket/fwmarkd"}, 110) = 0
sendmsg(4, {msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", iov_len=16}, {iov_base=NULL, iov_len=0}], msg_iovlen=2, msg_control=[{cmsg_len=20, cmsg_level=SOL_SOCKET, cmsg_type=SCM_RIGHTS, cmsg_data=[3]}], msg_controllen=24, msg_flags=0}, 0) = 16
recvfrom(4, "\0\0\0\0", 4, 0, NULL, NULL) = 4
close(4) 

This is from failed one posted above. First it tries AF_INET, which apparently fails and then it tries. AF_INET6, which apparently fails as well. I currently don't know the significance of recvfrom(4, "\266\377\377\377", 4, 0, NULL, NULL) = 4 instead of expected recvfrom(4, "\0\0\0\0", 4, 0, NULL, NULL) = 4 for the recvfrom call or of /dev/socket/fwmarkd but it likely related to the issue or can provide info for the failures. Will need time to look into it, unless someone else can.

write(1, "Enter pairing code: ", 20Enter pairing code: )    = 20
fstat(0, {st_mode=S_IFCHR|0600, st_rdev=makedev(0x88, 0), ...}) = 0
ioctl(0, TCGETS, {B38400 opost isig icanon echo ...}) = 0
read(0, 717733
"717733\n", 1024)               = 7
socket(AF_INET, SOCK_STREAM, IPPROTO_IP) = 3
bind(3, {sa_family=AF_INET, sin_port=htons(0), sin_addr=inet_addr("127.0.0.1")}, 16) = 0
getsockopt(3, SOL_SOCKET, SO_DOMAIN, [2], [4]) = 0
futex(0x74be1ec2f0, FUTEX_WAKE_PRIVATE, 2147483647) = 0
socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC, 0) = 4
connect(4, {sa_family=AF_UNIX, sun_path="/dev/socket/fwmarkd"}, 110) = 0
sendmsg(4, {msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", iov_len=16}, {iov_base=NULL, iov_len=0}], msg_iovlen=2, msg_control=[{cmsg_len=20, cmsg_level=SOL_SOCKET, cmsg_type=SCM_RIGHTS, cmsg_data=[3]}], msg_controllen=24, msg_flags=0}, 0) = 16
recvfrom(4, "\266\377\377\377", 4, 0, NULL, NULL) = 4
close(4)                                = 0
close(3)                                = 0
socket(AF_INET6, SOCK_STREAM, IPPROTO_IP) = 3
bind(3, {sa_family=AF_INET6, sin6_port=htons(0), sin6_flowinfo=htonl(0), inet_pton(AF_INET6, "::1", &sin6_addr), sin6_scope_id=0}, 28) = 0
getsockopt(3, SOL_SOCKET, SO_DOMAIN, [10], [4]) = 0
socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC, 0) = 4
connect(4, {sa_family=AF_UNIX, sun_path="/dev/socket/fwmarkd"}, 110) = 0
sendmsg(4, {msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", iov_len=16}, {iov_base=NULL, iov_len=0}], msg_iovlen=2, msg_control=[{cmsg_len=20, cmsg_level=SOL_SOCKET, cmsg_type=SCM_RIGHTS, cmsg_data=[3]}], msg_controllen=24, msg_flags=0}, 0) = 16
recvfrom(4, "\266\377\377\377", 4, 0, NULL, NULL) = 4
close(4)                                = 0
close(3)                                = 0
write(2, "* daemon not running; starting n"..., 47* daemon not running; starting now at tcp:5037
) = 47
pipe2([3, 4], O_CLOEXEC)                = 0

adb.txt

agnostic-apollo avatar Dec 14 '21 04:12 agnostic-apollo