-
Notifications
You must be signed in to change notification settings - Fork 66
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
When i try to pair to a device with valid paramters (ip, port and code) everything works fine.
The problem is when i use a wrong port/code to pair the device, currently the app crashes because it fails to read the msg return by adb.
Log:
An unhandled exception has occurred while executing the request.
System.FormatException: The input string 'FAIL' was not in a correct format.
at System.Number.ThrowFormatException[TChar](ReadOnlySpan`1 value)
at System.Int32.Parse(String s, NumberStyles style)
at AdvancedSharpAdbClient.AdbSocket.ReadStringAsync(CancellationToken cancellationToken)
at AdvancedSharpAdbClient.AdbClient.PairAsync(String host, Int32 port, String code, CancellationToken cancellationToken)After some digging i found the problem could be the adb tools itself, this is example of error when doing it directly in terminal with wrong port/code:
>adb pair 192.168.2.100:123123 123123
error: protocol fault (couldn't read status message): No errorSteps to reproduce the bug
Just call
await new AdbClient().PairAsync("some ip", 123, "some wrong code", CancellationToken.None);The app will crash throwing System.FormatException
Expected behavior
Expected to return an error in message instead of crashing.
NuGet package version
3.5.15
.NET Platform
.NET 10
Platform type
Windows
System version
>adb version
Android Debug Bridge version 1.0.41
Version 36.0.0-13206524
Installed as D:\Android\Android_Sdk\platform-tools\adb.exe
Running on Windows 10.0.26100IDE
Rider 2025
Additional context
After some debugging i found this are the messages return by adb socket:
"FAIL0027Failed: Unable to start pairing client." //When ip/port is wrong
"FAIL0031Failed: Wrong password or connection was dropped." //When pair code is wrong
"0045Successfully paired to 192.168.2.100:40613 [guid=REDACTED]" //On SuccessMetadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working