目前已经在IP端点0.0.0.0:13000监听器。 ? (TCP使用WCF)监听器、目前、IP、TCP

由网友(各安天命)分享简介:我试图弄清楚为什么端口正在重新启动计算机后甚至用!System.ServiceModel.AddressAlreadyInUseException:已存在的IP端点0.0.0.0:13000监听器。这可能发生,如果有另一个应用程序已经在此端点侦听,或者如果你有多个服务端点在你的服务主机具有相同IP终结点,但不兼容的绑定...

我试图弄清楚为什么端口正在重新启动计算机后甚至用!

  System.ServiceModel.AddressAlreadyInUseException:已存在的IP端点0.0.0.0:13000监听器。这可能发生,如果有另一个应用程序已经在此端点侦听,或者如果你有多个服务端点在你的服务主机具有相同IP终结点,但不兼容的绑定配置。 ---> System.Net.Sockets.SocketException:只有一个使用的每个套接字地址(协议/网络地址/端口)只允许使用
   在System.Net.Sockets.Socket.DoBind(端点endPointSnapshot,SocketAddress的SocketAddress的)
   在System.Net.Sockets.Socket.Bind(端点localEP)
   在System.ServiceModel.Channels.SocketConnectionListener.Listen()
   ---内部异常堆栈跟踪的结尾---
   在System.ServiceModel.Channels.SocketConnectionListener.Listen()
   在System.ServiceModel.Channels.TracingConnectionListener.Listen()
   在System.ServiceModel.Channels.ConnectionAcceptor.StartAccepting()
   在System.ServiceModel.Channels.ExclusiveTcpTransportManager.OnOpen()
   在System.ServiceModel.Channels.TransportManager.Open(TransportChannelListener channelListener)
   在System.ServiceModel.Channels.TransportManagerContainer.Open(SelectTransportManagersCallback selectTransportManagerCallback)
   在System.ServiceModel.Channels.TcpChannelListener`2.OnOpen(时间跨度超时)
   在System.ServiceModel.Channels.CommunicationObject.Open(时间跨度超时)
   在System.ServiceModel.Dispatcher.ChannelDispatcher.OnOpen(时间跨度超时)
   在System.ServiceModel.Channels.CommunicationObject.Open(时间跨度超时)
   在System.ServiceModel.ServiceHostBase.OnOpen(时间跨度超时)
   在System.ServiceModel.Channels.CommunicationObject.Open(时间跨度超时)
   在Microsoft.Tools.SvcHost.ServiceHostHelper.OpenService(ServiceInfo信息)
System.Net.Sockets.SocketException(0X80004005):只有一个使用的每个套接字地址(协议/网络地址/端口)只允许使用
   在System.Net.Sockets.Socket.DoBind(端点endPointSnapshot,SocketAddress的SocketAddress的)
   在System.Net.Sockets.Socket.Bind(端点localEP)
   在System.ServiceModel.Channels.SocketConnectionListener.Listen()
 

你如何找出哪些进程正在监听的端口(13000)? netstat显示没有在该端口上。

下面是我的App.config:

 <的System.Web>
    <编译调试=真/>
  < /system.web>
  <! - 在部署该服务库项目,配置文件的内容必须添加到主机的
  app.config文件。 System.Configuration不支持配置文件库。 - >
  < system.serviceModel>
    <服务>
      <服务名称=SomeTarget.SomeTargetService>
        <端点地址=绑定=customBindingbindingConfiguration =NetTcpBinding的
          合同=SomeTarget.ISomeTargetService>
          <身份>
            < D​​NS值=本地主机/>
          < /身分>
        < /端点>
        <端点地址=MEX绑定=mexTcpBindingbindingConfiguration =
          合同=IMetadataExchange接口/>
        <主机>
          < baseAddresses>
            <新增baseAddress =的net.tcp://本地主机:13000/>
          < / baseAddresses>
        < /主机>
      < /服务>
    < /服务>

    <绑定>
      < customBinding>
        <绑定名称=NetTcpBinding的的SendTimeout =00:05:00closeTimeout =00:00:30openTimeout =00:00:30receiveTimeout =00:05:00>
          < transactionFlow />
          < binaryMessageEncoding />
          < windowsStreamSecurity的ProtectionLevel =无/>
          < tcpTransport maxBufferPoolSize =524288
                        maxReceivedMessageSize =1024
                        maxBufferSize =1024>
            < connectionPoolSettings组名=默认leaseTimeout =00:05:00
                                    的idleTimeout =〇时02分00秒maxOutboundConnectionsPerEndpoint =20/>
          < / tcpTransport>
        < /装订>
      < / customBinding>
    < /绑定>

    <行为>
      < serviceBehaviors>
        <行为NAME =>
          < serviceMetadata httpGetEnabled =假httpsGetEnabled =FALSE/>
          < serviceDebug includeExceptionDetailInFaults =FALSE/>
        < /行为>
      < / serviceBehaviors>
    < /行为>
  < /system.serviceModel>

< /结构>
 
cad中一个一个端点拉伸出两个端点,变成一条直线,与逻辑不符,怎么才能画出这样的点

解决方案

我安装的.Net 4.5和我张贴的解决方案来帮助别人,如果不小心进入了后遇到此问题。 @ berkayk的回答上面的工作(暴露在不同的端口上的墨西哥),但我需要通过同一个口,露出两个端点。

假设你有两个端点,一个使用NetTcpBinding的,一个使用mexTcpBinding。 当使用默认绑定,有些默认使用的是计算OSEnvironmentHelper.ProcessorCount而不是硬codeD值,因为他们是在.NET 4.0中。

在我的情况下,使用一个名为NetTcpBinding的bindingConfiguration,对于财产的MaxConnections提供的值时为20设置属性的MaxConnections在NetTcpBinding的还设置它的TcpTransportBindingElement的MaxPendingConnections属性和TcpTransport的ConnectionPoolSettings.MaxOutboundConnectionsPerEndpoint属性相同的值。

在不使用命名NetTcpBinding的bindingConfiguration,并且仅采用缺省情况下,MaxPendingConnections属性进行计算,通过使用下面的算法:

 收益率(12 * OSEnvironmentHelper.ProcessorCount);
 

的mexTcpBinding的运输也计算它的使用上述算法MaxPendingConnections属性,所以,当既不是利用名为bindingConfiguration默认值匹配,并且不存在问题。

当使用名为NetTcpBinding的bindingConfiguration,传输的MaxPendingConnections为20,并且mexTcpBinding的运输的MaxPendingConnections是,我的机器,96.在值这两个端点共享相同端口是不相容的MaxPendingConnections差异上。

我还发现,出现这一问题的将ListenBackLog设置为好。 (我不知道所有可能存在的可能冲突的值。)的

要解决此问题,您可以创建自定义的MEX,对于NetTcpBinding的命名bindingConfiguration匹配结合。下面的例子:

 <端点绑定=NetTcpBinding的bindingConfiguration =TestNetTcpBinding
      合同=YourContract/>
<端点地址=MEX绑定=customBindingbindingConfiguration =TestMexBinding
      合同=IMetadataExchange接口/>

<绑定>
< customBinding>
<绑定名称=TestMexBinding>
&所述; tcpTransport maxPendingConnections =20将ListenBackLog =20>
< connectionPoolSettings组名=默认maxOutboundConnectionsPerEndpoint =20/>
< / tcpTransport>
< /装订>
< / customBinding>
< NetTcpBinding的>
<绑定名称=TestNetTcpBinding将ListenBackLog =20MAXCONNECTIONS =20/>
< / NetTcpBinding的>
< /绑定>
 

或者,也可以不指定被计​​算(如MAXCONNECTIONS和将ListenBackLog)的值,并且接受默认值(请注意,MaxOutboundConnectionsPerEndpoint将仍然保留的默认值10,因为它是不以同样的方式计算出的MaxPendingConnections属性是):

 <绑定名称=TestNetTcpBinding...... someOtherProperties除了将ListenBackLog和MAXCONNECTIONS />
 

注:问题描述如下:http://msdn.microsoft.com/en-us/library/aa702636.aspx,但考虑到唯一的解决办法就是揭露MEX不同的端口上。下面是在反射一些截图,显示.NET 4.0和4.5之间的差额计算MaxPendingConnections默认值时:

I'm trying to figure out why the port is being used even after restarting the computer!

System.ServiceModel.AddressAlreadyInUseException: There is already a listener on IP endpoint 0.0.0.0:13000. This could happen if there is another application already listening on this endpoint or if you have multiple service endpoints in your service host with the same IP endpoint but with incompatible binding configurations. ---> System.Net.Sockets.SocketException: Only one usage of each socket address (protocol/network address/port) is normally permitted
   at System.Net.Sockets.Socket.DoBind(EndPoint endPointSnapshot, SocketAddress socketAddress)
   at System.Net.Sockets.Socket.Bind(EndPoint localEP)
   at System.ServiceModel.Channels.SocketConnectionListener.Listen()
   --- End of inner exception stack trace ---
   at System.ServiceModel.Channels.SocketConnectionListener.Listen()
   at System.ServiceModel.Channels.TracingConnectionListener.Listen()
   at System.ServiceModel.Channels.ConnectionAcceptor.StartAccepting()
   at System.ServiceModel.Channels.ExclusiveTcpTransportManager.OnOpen()
   at System.ServiceModel.Channels.TransportManager.Open(TransportChannelListener channelListener)
   at System.ServiceModel.Channels.TransportManagerContainer.Open(SelectTransportManagersCallback selectTransportManagerCallback)
   at System.ServiceModel.Channels.TcpChannelListener`2.OnOpen(TimeSpan timeout)
   at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
   at System.ServiceModel.Dispatcher.ChannelDispatcher.OnOpen(TimeSpan timeout)
   at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
   at System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout)
   at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
   at Microsoft.Tools.SvcHost.ServiceHostHelper.OpenService(ServiceInfo info)
System.Net.Sockets.SocketException (0x80004005): Only one usage of each socket address (protocol/network address/port) is normally permitted
   at System.Net.Sockets.Socket.DoBind(EndPoint endPointSnapshot, SocketAddress socketAddress)
   at System.Net.Sockets.Socket.Bind(EndPoint localEP)
   at System.ServiceModel.Channels.SocketConnectionListener.Listen()

How do you figure out which process is listening to that port (13000)? Netstat shows nothing on that port.

Here's my App.config:

  <system.web>
    <compilation debug="true" />
  </system.web>
  <!-- When deploying the service library project, the content of the config file must be added to the host's 
  app.config file. System.Configuration does not support config files for libraries. -->
  <system.serviceModel>
    <services>
      <service name="SomeTarget.SomeTargetService">
        <endpoint address="" binding="customBinding" bindingConfiguration="NetTcpBinding"
          contract="SomeTarget.ISomeTargetService">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexTcpBinding" bindingConfiguration=""
          contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="net.tcp://localhost:13000" />
          </baseAddresses>
        </host>
      </service>
    </services>

    <bindings>
      <customBinding>
        <binding name="NetTcpBinding" sendTimeout="00:05:00" closeTimeout="00:00:30" openTimeout="00:00:30" receiveTimeout="00:05:00">
          <transactionFlow />
          <binaryMessageEncoding />
          <windowsStreamSecurity protectionLevel="None" />
          <tcpTransport maxBufferPoolSize="524288"
                        maxReceivedMessageSize="1024"
                        maxBufferSize="1024" >
            <connectionPoolSettings groupName="default" leaseTimeout="00:05:00"
                                    idleTimeout="00:02:00" maxOutboundConnectionsPerEndpoint="20" />
          </tcpTransport>
        </binding>
      </customBinding>
    </bindings>

    <behaviors>
      <serviceBehaviors>
        <behavior name="">
          <serviceMetadata httpGetEnabled="false" httpsGetEnabled="false" />
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

</configuration>

解决方案

I experienced this issue after installing .Net 4.5 and am posting a solution here to help others if they stumble into it. @berkayk's answer above worked (exposing the mex on a different port), but I needed to expose both endpoints through the same port.

Assume you have two endpoints, one using netTcpBinding and one using mexTcpBinding. When using the default bindings, some of the defaults are calculated using OSEnvironmentHelper.ProcessorCount instead of hard coded values as they were in .Net 4.0.

In my case, when using a named netTcpBinding bindingConfiguration, the value supplied for the MaxConnections property was 20. Setting the MaxConnections property on the NetTcpBinding also sets it's TcpTransportBindingElement's MaxPendingConnections property and the TcpTransport's ConnectionPoolSettings.MaxOutboundConnectionsPerEndpoint property to the same value.

When not using a named netTcpBinding bindingConfiguration, and only using the default, the MaxPendingConnections property was calculated by using the following algorithm:

 return (12 * OSEnvironmentHelper.ProcessorCount);

The mexTcpBinding's transport also calculated it's MaxPendingConnections property using the above algorithm, so when neither is using a named bindingConfiguration the default values match and there is no issue.

When using a named netTcpBinding bindingConfiguration, the transport's MaxPendingConnections was 20, and the mexTcpBinding's transport's MaxPendingConnections was, on my machine, 96. The difference in values for the MaxPendingConnections between these two endpoints sharing the same port is incompatible.

I also found that this issue occurred with the ListenBacklog set as well. (I do not know of all the possible conflicting values that may exist.)

To resolve the issue, you can create a custom binding for mex that matches the named bindingConfiguration for netTcpBinding. Example below:

<endpoint binding="netTcpBinding" bindingConfiguration="TestNetTcpBinding"
      contract="YourContract" />
<endpoint address="mex" binding="customBinding" bindingConfiguration="TestMexBinding"
      contract="IMetadataExchange" />

<bindings>
<customBinding>
<binding name="TestMexBinding">
<tcpTransport maxPendingConnections="20" listenBacklog="20">                   
<connectionPoolSettings groupName="default"  maxOutboundConnectionsPerEndpoint="20" />
</tcpTransport>
</binding>
</customBinding>
<netTcpBinding>
<binding name="TestNetTcpBinding" listenBacklog="20" maxConnections="20"/>
</netTcpBinding>
</bindings>

Or, you can not specify any values that are calculated (like maxConnections and listenBacklog) and accept the defaults (note that MaxOutboundConnectionsPerEndpoint will still retain the default value of 10 as it is not calculated in the same way that the MaxPendingConnections property is):

<binding name="TestNetTcpBinding" ...someOtherProperties except listenBacklog and maxConnections/>

Note: The issue is described here: http://msdn.microsoft.com/en-us/library/aa702636.aspx, but the only solution given is to expose the mex on a different port. Below are some screenshots in reflector that show the difference between .net 4.0 and 4.5 when calculating the MaxPendingConnections defaults:

阅读全文

相关推荐

最新文章