提问人:Mack 提问时间:11/1/2023 最后编辑:karelMack 更新时间:11/3/2023 访问量:52
AddressInUseException:通常只允许对每个套接字地址(协议/网络地址/端口)使用一次
AddressInUseException: Only one usage of each socket address (protocol/network address/port) is normally permitted
问:
我们在 Windows 服务器上有 1 个 .NET 项目,多个开发人员正在研究这个项目。所有开发人员都从同一窗口服务器上的不同位置访问项目。
由于 1 端口分配给项目,当多个开发人员运行/调试应用程序时,他们面临以下异常。
System.IO.IOException
HResult=0x80131620
Message=Failed to bind to address https://127.0.0.1:7085: address already in use.
Source=Microsoft.AspNetCore.Server.Kestrel.Core
StackTrace:
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.<BindEndpointAsync>d__3.MoveNext()
at Microsoft.AspNetCore.Server.Kestrel.Core.LocalhostListenOptions.<BindAsync>d__2.MoveNext()
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.AddressesStrategy.<BindAsync>d__2.MoveNext()
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.<BindAsync>d__0.MoveNext()
at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServerImpl.<BindAsync>d__33.MoveNext()
at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServerImpl.<StartAsync>d__30`1.MoveNext()
at Microsoft.AspNetCore.Hosting.GenericWebHostService.<StartAsync>d__37.MoveNext()
at Microsoft.Extensions.Hosting.Internal.Host.<StartAsync>d__12.MoveNext()
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.<RunAsync>d__4.MoveNext()
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.<RunAsync>d__4.MoveNext()
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.Run(IHost host)
at Microsoft.AspNetCore.Builder.WebApplication.Run(String url)
at Program.<Main>$(String[] args) in D:\New folder\WebApp\WebApp\Program.cs:line 67
This exception was originally thrown at this call stack:
[External Code]
Inner Exception 1:
AddressInUseException: Only one usage of each socket address (protocol/network address/port) is normally permitted.
Inner Exception 2:
SocketException: Only one usage of each socket address (protocol/network address/port) is normally permitted.
因此,替代方案是所有开发人员都需要更改各自项目的端口,尽管实际上项目是相同的并调试。但这不是意料之中的,还是真的?
除了为每个开发人员更改端口之外,我们还有其他选择吗?
答: 暂无答案
评论
LaunchSettings.json