WSATools icon indicating copy to clipboard operation
WSATools copied to clipboard

There's a rare chance that WSATools doesn't manage to start the Subsystem before installing an app

Open Simizfo opened this issue 3 years ago • 8 comments

Looks like this issue might be caused by a recent update to WSA.

This results in the "Cannot connect to WSA, make sure Dev mode is enabled, blah, blah" error.

Needs to be investigated.

If you've hit this please report here! Thanks.

Simizfo avatar Dec 01 '21 12:12 Simizfo

I get (a variant of?) this issue where it says "Check If ADB is enabled"

geophilips avatar Dec 03 '21 15:12 geophilips

Yes, it's the same issue. Looking into this! Thanks for reporting.

Simizfo avatar Dec 03 '21 15:12 Simizfo

Not sure if this is related specifically to Subsystem not being started, but I consistently get this error when installing anything. image

ADB version:

C:\Users\cat>adb --version
Android Debug Bridge version 1.0.41
Version 31.0.3-7562133
Installed as C:\adb\adb.exe

WSATools version: 0.1.70.0 WSA Version: 1.8.32828.0

Console outputs from trying to connect manually, using the IPs given by the WSA app:

C:\Users\cat>adb connect 127.0.0.1:58526
cannot connect to 127.0.0.1:58526: No connection could be made because the target machine actively refused it. (10061)

C:\Users\cat>adb connect 172.22.215.240:58526
cannot connect to 172.22.215.240:58526: No connection could be made because the target machine actively refused it. (10061)

I was, however, able to connect to port 5555 and install an APK manually (different IP at this point as I had restarted WSA)

C:\Users\cat\Downloads>adb connect 172.22.212.249:5555
connected to 172.22.212.249:5555

C:\Users\cat\Downloads>adb install Telegram.apk
Performing Streamed Install
Success

Ratismal avatar Dec 06 '21 17:12 Ratismal

Deleted the comment I made before this, I thought we were in another issue.

Thanks for reporting, looks like you've got ADB to connect to WSA using port 5555, which makes it the first time I see it changing port ever!

Wondering, though, where did you get the 5555 from? Was it reported on the WSA app?

Simizfo avatar Dec 07 '21 08:12 Simizfo

@Simizfo, I can tell you that I have recently discovered an issue with Windows and reserved ports. I have no idea why this continues to be an issue but random ports and port ranges will end up being reserved causing issues with a number of different applications.

I only discovered this after having an issue with several apps not being able to connect to their licensing servers which were running locally. The port would claim it was in use, though, I could not find a program using the port. After many hours of researching, thinking that maybe it was an issue with the licensing servers, I decided to look at WSL and Docker as a whole and found this comment on a Docker Issue which led me to resolving my licensing server issue. I am not sure why Windows is reserving lower numbered ports, but I didn't care to really keep digging into the issue.

Another thing to note, if not known, is that certain software tend to change their ports automatically if a port is reserved or in use. There are also environment variables such as ANDROID_ADB_SERVER_PORT for example, which may be helpful.

I know that these may not be related to this issue, however, I wanted to make the comment as I have noticed that it is very difficult to find any information on this issue, so I try to give people a heads up when I see anything that could be related.

One last note, it may help to automatically search for running instances of adb and look at the ports they are using. The way I went about this (obviously will not be the same on the backend) was to use the following:

Get-Process -Name "adb"
ProcessName    Id
-----------    --
adb         32484
Get-NetTCPConnection -OwningProcess 13744
LocalAddress                        LocalPort RemoteAddress                       RemotePort State       AppliedSetting
------------                        --------- -------------                       ---------- -----       --------------
0.0.0.0                             5040      0.0.0.0                             0          Listen

Sorry for the unrelated comment on an older(?) issue, but I would much rather provide the information and have it not be useful than assume it is unrelated and have someone researching for days into an issue that someone may have readily available.

Thanks for your hard work. It is definitely appreciated!

Ceus avatar Jan 04 '22 06:01 Ceus

@Ceus you're "sorry"? I guess us developers dream of a world where all issues are detailed like you did. Definitely thanks for that!

Back on the issue: As I was saying, this is the first time someone reports the port gets automatically changed, and yeah, softwares usually do that when their default port is already being used.

I guess I'll have to find a way to programmatically discover where WSA exposes ADB, or just finish developing the ADB port setting in WSATools setting.

Thanks again for reporting!

Simizfo avatar Jan 04 '22 10:01 Simizfo