我有Windows服务,使用WCF服务主机来侦听TCP端口61000上的连接。当我尝试启动该服务时,出现错误:
Service cannot be started. System.ServiceModel.AddressAlreadyInUseException: HTTP could not register URL http://+:61000/ because TCP port 61000 is being used by another application. ---> System.Net.HttpListenerException: The process cannot access the file because it is being used by another process at System.Net.HttpListener.AddAll() at System.Net.HttpListener.Start() at System.ServiceModel.Channels.SharedHttpTransportManager.OnOpen() --- End of inner exception stack trace --- at System.ServiceModel.Channels.SharedHttpTransportManager.OnOpen() at System.ServiceModel.Channels.TransportManager.Open(TransportChannelListener channelListener) at System.ServiceModel.Channels.TransportManagerContainer.Open(SelectTransportManagersCallback selectTransportManagerCallback) at System.ServiceModel.Channels.HttpChannelListener.OnOpen(TimeSpan timeout) at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) at System.ServiceModel.Dispatcher.ChannelDispatcher.OnOpen(TimeSpan timeout) at...
一个快速的netstat -a
显示在端口61000上没有任何监听。我还发现有几篇post提到使用netstat
保留命名空间 ,但运行该服务的帐户具有pipe理员权限,因此不应该是必需的。
任何其他想法,为什么我得到这个消息?
此服务在64位Windows Server 2008 R2 Standard上运行。
如果程序closures时在端口上有一个打开的连接,并且TCP没有完成四次closures握手,那么在超时过期之前套接字将保持“半closures”状态(即使程序已经终止),并会阻止您再次打开该端口。 各种实现具有不同的超时时间,通常从1/2秒到2分钟不等。