问题描述
我有一个WCF服务写在.NET 4中,并暴露在的net.tcp。任何时候,我尝试的绑定配置属性设置为的MaxConnections东西高于10我AddressAlreadyInUseException。
为什么会越来越扔在MaxConnection设置?
(如果它很重要,我是在服务器2008 R2标准采用了4核CPU和4 GB RAM)
<绑定名称=NetTcpBinding的closeTimeout =00:01:00
openTimeout =00:01:00receiveTimeout =00:10:00的SendTimeout =00:01:00
transferMode =缓冲hostNameComparisonMode =StrongWildcard
maxBufferPoolSize =524288maxBufferSize =25000000
maxReceivedMessageSize =25000000MAXCONNECTIONS =50>
< readerQuotas MAXDEPTH =32maxStringContentLength =25000000
maxArrayLength =25000000maxBytesPerRead =25000000maxNameTableCharCount =25000000/>
<安全模式=无/>
< /装订>
<服务behaviorConfiguration =ApiService.ServiceBehaviorNAME =Api.Service.PlatformApiService>
<端点
地址=/搜索
绑定=NetTcpBinding的
bindingConfiguration =NetTcpBinding的
合同=IApiService/>
<端点
地址=MEX
绑定=mexTcpBinding
bindingConfiguration =NetTcpBinding的
合同=IMetadataExchange接口/>
<主机>
< baseAddresses>
<新增baseAddress =的net.tcp://本地主机:8094 / API / >
< / baseAddresses>
< /主机>
< /服务>
您MEX端点定义绑定配置,它不是你的配置片段的一部分。
MaxConnection定义了特定端口的连接池。目前使用的是两个端点它们共享单个端口 - ApiService和元数据端点。你改变你绑定配置设置前两种enpoints使用默认值 - 10连接池中。当您更改了该值就只影响到一个端点第二端点仍需要10个连接=>例外。该解决方案是:
- 在公开不同的端口上的元数据终结点。
- 创建的MEX终结自定义绑定。默认mexTcpBinding不允许更改的MaxConnections。在自定义绑定设置为MaxConnection相同的值。
- 尝试使用port分享。
目前至少第一想法应该工作。
I have a WCF service written in .net 4, and exposed over net.tcp. Any time I try to set the MaxConnections property of the binding configuration to something higher than 10 I am AddressAlreadyInUseException.
Why would that be getting thrown on the MaxConnection setting?
(if it matters, I am on Server 2008 R2 Standard with a 4 core CPU and 4 gb ram)
<binding name="NetTcpBinding" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
transferMode="Buffered" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxBufferSize="25000000"
maxReceivedMessageSize="25000000" maxConnections="50">
<readerQuotas maxDepth="32" maxStringContentLength="25000000"
maxArrayLength="25000000" maxBytesPerRead="25000000" maxNameTableCharCount="25000000" />
<security mode="None" />
</binding>
<service behaviorConfiguration="ApiService.ServiceBehavior" name="Api.Service.PlatformApiService">
<endpoint
address="/Search"
binding="netTcpBinding"
bindingConfiguration="NetTcpBinding"
contract="IApiService" />
<endpoint
address="mex"
binding="mexTcpBinding"
bindingConfiguration="NetTcpBinding"
contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:8094/Api/" />
</baseAddresses>
</host>
</service>
Your mex endpoint defines binding configuration which is not part of your configuration snippet.
MaxConnection defines pooling of connections for given port. At the moment you are using two endpoints which share single port - ApiService and Metadata endpoints. Before you changes setting in your binding configuration both enpoints used default value - 10 connections in a pool. When you changed the value it affected only one endpoint second endpoint still demands 10 connections => exception. The solutions are:
- Expose metadata endpoint on different port.
- Create custom binding for Mex endpoint. Default mexTcpBinding does not allow changing MaxConnections. Set same value for MaxConnection in custom binding.
- Try to use port sharing.
At least first idea should work.
这篇关于WCF MAXCONNECTIONS财产的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!