-
Couldn't load subscription status.
- Fork 381
Fix dotnet-dsrouter Android port reverse local/remote ports. #4342
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix dotnet-dsrouter Android port reverse local/remote ports. #4342
Conversation
|
I built a local branch based on this PR and validated that dotnet-dsrouter
Started an Android app with dotnet-trace
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Appears to work for me, too:
D:\src\dotnet\diagnostics\src\Tools\dotnet-dsrouter [lateralusX/fix-android-port-reverse]> dotnet run -- android -v debug
WARNING: dotnet-dsrouter is a development tool not intended for production environments.
How to connect current dotnet-dsrouter pid=12968 with android device and diagnostics tooling.
Start an application on android device with ONE of the following environment variables set:
[Default Tracing]
DOTNET_DiagnosticPorts=127.0.0.1:9000,nosuspend,connect
[Startup Tracing]
DOTNET_DiagnosticPorts=127.0.0.1:9000,suspend,connect
Run diagnotic tool connecting application on android device through dotnet-dsrouter pid=12968:
dotnet-trace collect -p 12968
See https://learn.microsoft.com/en-us/dotnet/core/diagnostics/dotnet-dsrouter for additional details and examples.
info: dotnet-dsrouter-12968[0]
Starting dotnet-dsrouter using pid=12968
dbug: dotnet-dsrouter-12968[0]
Using default IPC server path, dotnet-diagnostic-dsrouter-12968.
dbug: dotnet-dsrouter-12968[0]
Attach to default dotnet-dsrouter IPC server using --process-id 12968 diagnostic tooling argument.
dbug: dotnet-dsrouter-12968[0]
Executing D:\android-toolchain\sdk\platform-tools\adb reverse --list.
fail: dotnet-dsrouter-12968[0]
stderr: * daemon not running; starting now at tcp:5037
* daemon started successfully
dbug: dotnet-dsrouter-12968[0]
Executing D:\android-toolchain\sdk\platform-tools\adb reverse tcp:9000 tcp:9001.
info: dotnet-dsrouter-12968[0]
Starting IPC server (dotnet-diagnostic-dsrouter-12968) <--> TCP server (127.0.0.1:9001) router.
Then I can get a profile from a device:
> dotnet-trace collect -p 12968 --format speedscope
No profile or providers specified, defaulting to trace profile 'cpu-sampling'
Provider Name Keywords Level Enabled By
Microsoft-DotNETCore-SampleProfiler 0x0000F00000000000 Informational(4) --profile
Microsoft-Windows-DotNETRuntime 0x00000014C14FCCBD Informational(4) --profile
Process : D:\src\dotnet\diagnostics\artifacts\bin\dotnet-dsrouter\Debug\net6.0\dotnet-dsrouter.exe
Output File : D:\src\dotnet-dsrouter.exe_20231019_102830.nettrace
[00:00:00:04] Recording trace 2.7577 (MB)
Press <Enter> or <Ctrl+C> to exit...
Stopping the trace. This may take several minutes depending on the application being traced.
Trace completed.
Writing: D:\src\dotnet-dsrouter.exe_20231019_102830.speedscope.json
Conversion complete
The use of automatic port forwarding on Android device used the same port as local and remote, that should be possible, but turns out there is some issue with
adbaround that configuration when running against a physical Android device (works when using port forwarding/reverse against Android emulator).This PR change the port defaults and align to Xamarin Android documentation as well as using different ports for local and remove when using -
tcpsor -tcpcarguments together with--forward-port android.When running using the "Android" connect profile,
dotnet-dsrouter androidwe will default to 9001 as local/host and 9000 as remote/device port.When running with -
tcpsor -tcpcwe will use passed port as local/host port and then set the remote/device port to local/host port - 1 in call toadb reverse|forward.Fixes #4337