-
Notifications
You must be signed in to change notification settings - Fork 385
Add tooling TCP/IP support to enable diagnostics on IOS/Android runtime platforms. #2050
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
Add tooling TCP/IP support to enable diagnostics on IOS/Android runtime platforms. #2050
Conversation
|
//CC @josalem |
|
Hold of on review, I will add at least on of the proxy configurations into this PR, the named-pipe/unixdomain socket client -> TCP/IP listener, meaning we can have runtime work in reversed connect scenario against tools setup in reversed connect scenarios. This includes adding a new tool representing the proxy, planning on using |
Can you be more specific about what 'code will re-create a new instance of the server'? It feels like you are adding a lot of CancellationToken passing via constructors (a pattern that I've never seen in any code) to fix a issue in, maybe, dotnet-counters that really should be fixed there rather than forcing it down into the lower primitives. In my opinion, if something is finished with the ReversedDiagnosticsServer, just call DisposeAsync on it and don't recreate it. No need for more CancellationTokens and combining them into new sources when disposing the object should do. |
|
Did it this way since it was close to how things currently work adding ability to see the difference between cancel a pending This could of course be solved in different ways by altering how One option could be to add a flag to the server transport indicating that we are pending a shutdown and then the code can check that flag instead of cancel token to decide if it should re-create the server transport. To make that work we also need access to the server transport instance inside |
|
The problem is in |
That's the pattern used even with this fix, the additional token is internal to |
I believe this simplest way to solve this is to dispose the transport before the AcceptAsync call can observe the cancellation. This way, the transport will its I've created a PR that should fix this issue separately from your TCP/IP addition: #2064 |
|
I was a little hesitant to take that route initially, disposing an object will still in use in async operations, but if you believe it's ok and won't cause to problematic side effects I'm totally fine backing out that part from this PR and rebase on top of what you did in #2064. |
aee4d48 to
41ccb6c
Compare
|
Excluded fix for not recreating |
|
//CC @josalem You can now start doing the review of this PR. |
|
@lateralusX Just FYI @josalem is out this week |
josalem
left a comment
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.
First round of comments. I'm going to take a deeper look at the routing code still.
src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsIpc/IpcTcpSocketTransport.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsServerRouter/DiagnosticsServerRouter.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsServerRouter/DiagnosticsServerRouter.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsServerRouter/DiagnosticsServerRouter.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsServerRouter/DiagnosticsServerRouter.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsServerRouter/DiagnosticsServerRouter.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsServerRouter/DiagnosticsServerRouter.cs
Outdated
Show resolved
Hide resolved
...icrosoft.Diagnostics.NETCore.Client/DiagnosticsServerRouter/DiagnosticsServerRouterRunner.cs
Outdated
Show resolved
Hide resolved
jander-msft
left a comment
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.
Initial comments; I'll take another pass when these and John's comments are addressed.
src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsIpc/IpcSocketTransport.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsIpc/IpcServerTransport.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsIpc/IpcServerTransport.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsIpc/IpcTcpSocketTransport.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsIpc/IpcTcpSocketTransport.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsIpc/IpcTcpSocketTransport.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsIpc/IpcTcpSocketTransport.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsIpc/IpcTcpSocketTransport.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsIpc/IpcSocketTransport.cs
Outdated
Show resolved
Hide resolved
|
@josalem, @jander-msft, would be great if we could get progress on this PR so we could get it merged (since it will be needed for end2end testing of EventPipe on mobile). I believe all comments so far in this PR have been addressed. |
src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsServerRouter/DiagnosticsServerRouter.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsServerRouter/DiagnosticsServerRouter.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsServerRouter/DiagnosticsServerRouter.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsServerRouter/DiagnosticsServerRouter.cs
Show resolved
Hide resolved
src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsServerRouter/DiagnosticsServerRouter.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsServerRouter/DiagnosticsServerRouter.cs
Show resolved
Hide resolved
src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsServerRouter/DiagnosticsServerRouter.cs
Show resolved
Hide resolved
df54ec4 to
184ca11
Compare
josalem
left a comment
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.
I think this is in a good state to iterate on for preview status. That being said, @hoyosjs is stabilizing the repo for a release. Let's wait a day and check in tomorrow before we merge.
|
@josalem, looks like I don't have right permissions to merge. |
cb84681 to
ff7d474
Compare
Add support for TCP/IP in ReversedDiagnosticServer so it can be used by Mono runtime platforms that can't use existing named pipe or Unix domain socket support (like IOS/Android). By default all existing tooling won't include support for running the ReversedDiagnosticServer with TCP/IP enabled, meaning that they won't be affected by change.
Added new tool,
dotnet-dsrouterused to connect existing IPC based tooling with TCP based runtime.Router implement reverse connect protocol (client-server mode), meaning that the diagnostic tooling will act as a IPC server and runtime will act as a TCP client, meaning that the router sets up a TCP listener and connect towards tooling using IPC client (namedpipe/unix domain socket). Tool currently accepts a couple of arguments:
dotnet-dsrouter client-server --ipc-client [IPCPath] --tcp-server [host:port] --runtime-timeout --verboseclient-servercommand enables the IPC client, TCP server mode.ipc-clientoption sets the IPC path to connect against, normally what's used when launching diagnostic tool with --diagnostic-port argument.tcp-serveroption set the TCP address/addresses to bind and listen.runtime-timeoutoption indicating if router should shutdown if runtime doesn't connect before timeout (seconds). Default timeout is infinite, router will wait for runtime to connect.verboseoption to enable verbose logging in router.tcp-servercan be any supported IPv4/IPv6 address, including * that will bind to all interfaces and if machine supports IPv6, enable dual mode, binding all IPv4 and IPv6 interfaces. It is also possible to restrict to just use any IPv4 by using 0.0.0.0, any IPv6 using [::], IPv4 loopback, 127.0.0.1, IPv6 loopback [::1], host name (will only bind first resolved interface), localhost (will only bind first resolved interface) or any specific IPv4 or IPv6 interface.Router also implements server-server mode where diagnostic tools act as IPC clients and runtime as a TCP/IP client, so router is setup with a front end ipc server and a back end ipc server.
dotnet-dsrouter server-server --ipc-server [IPCPath] --tcp-server [host:port] --runtime-timeout--verbosemost arguments same as above:
server-servercommand enables the IPC server, TCP server router mode.ipc-serveroption sets the IPC path used by ipc server. If excluded or empty, ipc server will use default diagnostic naming of ipc server path.ipc-server will default to same naming schema as used by native runtime ipc listener, tcp-server will default to 127.0.0.1:0 where 0 will be bound to a dynamic port.
TCP/IP support in Diagnostic Server is added through the following PR:
dotnet/runtime#48154