OmniSharp / omnisharp-roslyn

OmniSharp server (HTTP, STDIO) based on Roslyn workspaces
MIT License
1.79k stars 419 forks source link

Failed to bind to address http://localhost:2000 An attempt was made to access a socket in a way forbidden by its access permissions #1502

Open simendsjo opened 5 years ago

simendsjo commented 5 years ago

I'm unable to build master as some test fails with: Failed to bind to address http://localhost:2000 An attempt was made to access a socket in a way forbidden by its access permissions I've tried running as Administrator, and netstat.exe -a -b | grep ':2000' doesn't return any results.

C:\Users\ME\code\omnisharp-roslyn>"C:\Users\ME\code\omnisharp-roslyn\artifacts\publish\OmniSharp.Http.Driver\win7-x64\OmniSharp.exe" -s C:/Users/ME/code/omnisharp-roslyn\src\OmniSharp.Http.Driver
info: OmniSharp.Services.DotNetCliService[0]
      DotNetPath set to dotnet
info: OmniSharp.MSBuild.Discovery.MSBuildLocator[0]
      Located 5 MSBuild instance(s)
                  1: Visual Studio Professional 2019 16.0.28803.352 - "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin"
                  2: Visual Studio Build Tools 2017 15.9.28307.557 - "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin"
                  3: Visual Studio Professional 2017 15.9.28307.586 - "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin"
                  4: Visual Studio Enterprise 2019 16.0.28729.10 - "C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin"
                  5: StandAlone 15.0 - "C:\Users\ME\code\omnisharp-roslyn\artifacts\publish\OmniSharp.Http.Driver\win7-x64\.msbuild\Current\Bin"
info: OmniSharp.MSBuild.Discovery.MSBuildLocator[0]
      Registered MSBuild instance: Visual Studio Professional 2019 16.0.28803.352 - "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin"
info: OmniSharp.Http.Startup[0]
      Starting OmniSharp on Windows 6.2.9200.0 (x64)
info: OmniSharp.Cake.CakeProjectSystem[0]
      Detecting Cake files in 'C:/Users/ME/code/omnisharp-roslyn\src\OmniSharp.Http.Driver'.
info: OmniSharp.Cake.CakeProjectSystem[0]
      Could not find any Cake files
info: OmniSharp.WorkspaceInitializer[0]
      Project system 'OmniSharp.DotNet.DotNetProjectSystem' is disabled in the configuration.
info: OmniSharp.MSBuild.ProjectSystem[0]
      No solution files found in 'C:/Users/ME/code/omnisharp-roslyn\src\OmniSharp.Http.Driver'
info: OmniSharp.MSBuild.ProjectManager[0]
      Queue project update for 'C:\Users\ME\code\omnisharp-roslyn\src\OmniSharp.Http.Driver\OmniSharp.Http.Driver.csproj'
info: OmniSharp.Script.ScriptProjectSystem[0]
      Detecting CSX files in 'C:/Users/ME/code/omnisharp-roslyn\src\OmniSharp.Http.Driver'.
info: OmniSharp.Script.ScriptProjectSystem[0]
      Could not find any CSX files
info: OmniSharp.WorkspaceInitializer[0]
      Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpWorkspaceOptionsProvider
info: OmniSharp.MSBuild.ProjectManager[0]
      Loading project: C:\Users\ME\code\omnisharp-roslyn\src\OmniSharp.Http.Driver\OmniSharp.Http.Driver.csproj
info: OmniSharp.WorkspaceInitializer[0]
      Configuration finished.
info: OmniSharp.Http.Startup[0]
      Omnisharp server running on port '2000' at location 'C:/Users/ME/code/omnisharp-roslyn\src\OmniSharp.Http.Driver' on host -1.
System.IO.IOException: Failed to bind to address http://localhost:2000. ---> System.AggregateException: One or more errors occurred. ---> System.Net.Sockets.SocketException: An attempt was made to access a socket in a way forbidden by its access permissions
   at System.Net.Sockets.Socket.DoBind(EndPoint endPointSnapshot, SocketAddress socketAddress)
   at System.Net.Sockets.Socket.Bind(EndPoint localEP)
   at Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.SocketTransport.BindAsync()
   at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServer.<>c__DisplayClass22_0`1.<<StartAsync>g__OnBind|0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.<BindEndpointAsync>d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Server.Kestrel.Core.LocalhostListenOptions.<BindAsync>d__2.MoveNext()
   --- End of inner exception stack trace ---
   --- End of inner exception stack trace ---
   at Microsoft.AspNetCore.Server.Kestrel.Core.LocalhostListenOptions.<BindAsync>d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.AddressesStrategy.<BindAsync>d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.<BindAsync>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServer.<StartAsync>d__22`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Hosting.Internal.WebHost.<StartAsync>d__26.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Hosting.Internal.WebHost.Start()
   at OmniSharp.Http.Host.Start() in C:\Users\ME\code\omnisharp-roslyn\src\OmniSharp.Http\Host.cs:line 57
   at OmniSharp.Http.Driver.Program.<>c__DisplayClass0_1.<Main>b__1() in C:\Users\ME\code\omnisharp-roslyn\src\OmniSharp.Http.Driver\Program.cs:line 20
   at OmniSharp.CommandLineApplication.<>c__DisplayClass11_0.<OnExecute>b__0() in C:\Users\ME\code\omnisharp-roslyn\src\OmniSharp.Host\CommandLineApplication.cs:line 61
   at OmniSharp.CommandLineApplication.Execute(IEnumerable`1 args) in C:\Users\ME\code\omnisharp-roslyn\src\OmniSharp.Host\CommandLineApplication.cs:line 44
   at OmniSharp.Http.Driver.Program.<>c__DisplayClass0_0.<Main>b__0() in C:\Users\ME\code\omnisharp-roslyn\src\OmniSharp.Http.Driver\Program.cs:line 25
   at OmniSharp.HostHelpers.Start(Func`1 action) in C:\Users\ME\code\omnisharp-roslyn\src\OmniSharp.Host\HostHelpers.cs:line 29
An error occurred when executing task 'ExecuteRunScript'.

----------------------------------------
Teardown
----------------------------------------
Shutting down MSBuild server...
Shutting down VB/C# compiler server...
MSBuild server shut down successfully.
VB/C# compiler server shut down successfully.
Error: One or more errors occurred.
        Failed to run C:/Users/ME/code/omnisharp-roslyn\artifacts\scripts\OmniSharp.Http.cmd
bjorkstromm commented 5 years ago

Does all HTTP test fails, or is it random? I was wondering if the port is left open hanging for some time when proceeding to next test (see https://github.com/aspnet/KestrelHttpServer/issues/2277#issuecomment-366317570).

You can also skip HTTP tests in your build by removing the following line: https://github.com/OmniSharp/omnisharp-roslyn/blob/d642aefc947dfaae7cdeac4c98346897200134d8/build.json#L23

Also, if you want a quick build (without any tests) just for getting artifacts, you can run:

.\build.ps1 -Target Quick
simendsjo commented 5 years ago

Does all HTTP test fails, or is it random?

Not sure. Tried running it again, but I cannot see any difference in the output. I cannot see any indication of work being done at all, so I'm not sure it's the same place or not.