Remote Debugging Testing: System.Net.Sockets.SocketException is thrown during debug test in WSL(Ubuntu)

Keuschnig Marko 1 Reputation point
2022-01-27T08:49:18.753+00:00

When I try to debug a test using ubuntu in wsl a "connection timed out" exception is thrown and the test are not running.

Command line: wsl -d Ubuntu-20.04 -- export DOTNET_ROLL_FORWARD_ON_NO_CANDIDATE_FX=2 ; dotnet '/mnt/c/program files/microsoft visual studio/2022/enterprise/common7/ide/commonextensions/microsoft/testwindow/RemoteAgent/TestWindowRemoteAgent.dll' start --hostname 192.168.178.54 --port 55711
Command exit code: 1
Command output: Connecting to 192.168.178.54:55711
Command error: Unhandled exception: System.Net.Sockets.SocketException (110): Connection timed out
   at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ThrowException(SocketError error, CancellationToken cancellationToken)
   at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.System.Threading.Tasks.Sources.IValueTaskSource.GetResult(Int16 token)
   at System.Threading.Tasks.ValueTask.ValueTaskSourceAsTask.<>c.<.cctor>b__4_0(Object state)
--- End of stack trace from previous location ---
   at System.Net.Sockets.TcpClient.CompleteConnectAsync(Task task)
   at Microsoft.VisualStudio.TestWindow.RemoteAgent.Program.<>c.<<Main>b__3_0>d.MoveNext() in D:\a\_work\1\s\src\TestWindow\RemoteAgent\Program.cs:line 54
--- End of stack trace from previous location ---
   at System.CommandLine.Invocation.CommandHandler.GetResultCodeAsync(Object value, InvocationContext context)
   at System.CommandLine.Invocation.ModelBindingCommandHandler.InvokeAsync(InvocationContext context)
   at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_0.<<BuildInvocationChain>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<UseParseErrorReporting>b__19_0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass14_0.<<UseHelp>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass22_0.<<UseVersionOption>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass21_0.<<UseTypoCorrections>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<UseSuggestDirective>b__20_0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<UseParseDirective>b__18_0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<UseDebugDirective>b__10_0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<RegisterWithDotnetSuggest>b__9_0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass12_0.<<UseExceptionHandler>b__0>d.MoveNext()
  • Visual Studio Version: Microsoft Visual Studio Enterprise 2022 (64-bit) Version 17.0.5
  • Ubuntu: Ubuntu-20.04 (Default)
  • Installed .net Version in Ubuntu: 6.0.101

testenvironments.json

 {
   "version": "1", // value must be 1
   "environments": [
     {
       "name": "Ubuntu",
       "type": "wsl",
       "wslDistribution": "Ubuntu-20.04"
     }
   ]
 }
Developer technologies Visual Studio Debugging
Developer technologies Visual Studio Testing
{count} votes

1 answer

Sort by: Most helpful
  1. fx_mborm 1 Reputation point
    2022-02-06T13:40:59.867+00:00

    I have the exact same issue as @KeuschnigMarko. Disabling the firewall does not changed anything @Tianyu Sun-MSFT .
    Stopping WSL before running the test does not changed anything for me @Alexander .
    I have not done a deep analysis but the "ServiceHub.TestWindowStoreHost.exe" is listening on ANY and on the port. So I guess it has indeed something todo with the docker or WSL network integration and not visual studio itself, as I have the same issue with docker containers.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.