获取AddressAlreadyInUseException升级到.NET 4.5后, [英] Getting AddressAlreadyInUseException after upgrading to .NET 4.5

查看:352
本文介绍了获取AddressAlreadyInUseException升级到.NET 4.5后,的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近安装(安装previously 4.0)新的.NET框架4.5我的服务器上,并i'm得到一个System.ServiceModel.AddressAlreadyInUseException当我开始我的Windows服务,公开WCF终结点。

I recently installed the new .NET Framework 4.5 (previously was 4.0 installed) on my Server and i´m getting a System.ServiceModel.AddressAlreadyInUseException when i start my Windows Service that exposes WCF endpoints.

System.ServiceModel.AddressAlreadyInUseException:已经有一个   听众对IP端点0.0.0.0:56543。这可能发生,如果有   另一个应用程序已经在此端点侦听,或者如果你有   在您的服务主机相同的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.BufferedConnectionListener.Listen()在   System.ServiceModel.Channels.ExclusiveTcpTransportManager.OnOpen()
  在   System.ServiceModel.Channels.TransportManager.Open(TransportChannelListener   channelListener)在   System.ServiceModel.Channels.TransportManagerContainer.Open(SelectTransportManagersCallback   selectTransportManagerCallback)在   System.ServiceModel.Channels.TransportChannelListener.OnOpen(时间跨度   超时)在   System.ServiceModel.Channels.ConnectionOrientedTransportChannelListener.OnOpen(时间跨度   超时)在   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(时间跨度   超时)在Qosit.Infrastructure.UnisServer.OnStart(字串[] args)

System.ServiceModel.AddressAlreadyInUseException: There is already a listener on IP endpoint 0.0.0.0:56543. 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.BufferedConnectionListener.Listen() 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.TransportChannelListener.OnOpen(TimeSpan timeout) at System.ServiceModel.Channels.ConnectionOrientedTransportChannelListener.OnOpen(TimeSpan timeout) 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 Qosit.Infrastructure.UnisServer.OnStart(String[] args)

我的WCF终端的配置类似的:

The configuration of my WCF endpoints looks like that:

<system.serviceModel>
    <bindings>
      <netTcpBinding>
        <binding name="NetTcpBindingConfiguration" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions" hostNameComparisonMode="StrongWildcard" listenBacklog="10" maxBufferPoolSize="524288" maxBufferSize="65536" maxConnections="10" maxReceivedMessageSize="65536">
          <readerQuotas maxDepth="32" maxStringContentLength="5242880" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" />
        </binding>
      </netTcpBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior name="">
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
        <behavior name="MEX">
          <serviceMetadata/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <services>
      <service behaviorConfiguration="MEX" name="MyAssembly.MyNamespace.MyService">      
        <endpoint address="net.tcp://localhost:56543/MyService"
          binding="netTcpBinding" bindingConfiguration="NetTcpBindingConfiguration" contract="MyAssembly.MyNamespace.MyServiceInterface" />
        <endpoint address="net.tcp://localhost:56543/MEX" binding="mexTcpBinding"
          contract="IMetadataExchange" />
      </service>
    </services>
  </system.serviceModel>

我认为这是与使用同一端口的MEX终结点,但林不知道如何将它正确地升级到.NET框架4.5后配置。

I think it has something to do with the MEX endpoint that uses the same port, but im not sure how to configure it correctly after upgrading to .NET Framework 4.5.

有没有在WCF的变化,使这些配置会引发异常?

Was there a change in WCF so that these configuration raises an exception?

推荐答案

这是因为在使用同一端口同时为netTcp端点和MEX端点记录的此处指部的服务端点,并使用NetTcpBinding的一个MEX端点之间共享端口。在4.0的默认值,将ListenBackLog 的MaxConnections 分别为10.在4.5这些默认值被修改为12 * ProcessorCount。当您尝试共享NetTcpBinding的之间的端口和MEX端点只要你有这两个属性不同的值,此异常情况。在4.0这个工作得很好,你已经设置这些为默认值(10),因此这些设置不会在两个端点不同。但在4.5,这些都留给10 netTcp终点,而是计算为12 * ProcessorCount。所以异常。

This is because of some limitations in using the same port for both the netTcp endpoint and mex endpoint documented here refer section "Sharing a port between a service endpoint and a mex endpoint using the NetTcpBinding". In 4.0 the defaults for listenBackLog and MaxConnections were 10. In 4.5 these defaults were revised as 12 * ProcessorCount. This exception happens when you try to share a port between netTcpBinding and mex endpoint provided you have different values for these two properties. In 4.0 this worked fine as you have set these to the default values (10) and thus these settings do not differ on both endpoints. But in 4.5 these are left as 10 for netTcp endpoint, but computed as 12* ProcessorCount. So the exception.

要解决这个问题,有2种方式:

To solve this issue there are 2 ways:

  1. 删除从配置这些设置(将ListenBackLog 的MaxConnections )。通过这种方式,你将自动获得12 *处理器数量默认是>比4.0的缺省值。
  2. 文档 <描述遵循的不同端口上配置MEX终结点周围的工作/ LI>
  1. Remove these settings (listenBackLog and MaxConnections) from the config. In this way you will get a default of 12 * Processor count automatically which is > than 4.0 defaults.
  2. Follow the work around of configuring mex endpoint on a different port as described in documentation

请看看<一href="http://blogs.msdn.com/b/praburaj/archive/2012/10/16/nettcpbinding-amp-mextcpbinding-sharing-same-port-throws-addressalreadyinuseexception-on-upgrade-to-net-4-5.aspx">this博客更多的细节。

这篇关于获取AddressAlreadyInUseException升级到.NET 4.5后,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆