LN 客户端通过 netTCPBinding 的 WCF 服务超时,美国客户端工作正常
我有一个通过 TCP 绑定公开的 WCF 服务,在纽约的服务器上运行。连接到该服务并从美洲连接到该服务的客户获取结果时没有任何问题,但来自伦敦/欧洲的客户却遇到了问题。我不太确定为什么会发生此超时问题,但以下是客户端和服务器设置。
服务器
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="TCPBinding_IDataService"
receiveTimeout="00:20:00"
openTimeout="00:05:00"
maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647"
maxConnections="10"
maxBufferSize="2147483647">
<readerQuotas maxDepth="2147483647"
maxStringContentLength="2147483647"
maxArrayLength="2147483647"
maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647"/>
<security mode="Message">
<message clientCredentialType="Windows"/>
</security>
</binding>
</netTcpBinding>
</bindings>
<services>
<service behaviorConfiguration="DataServiceBehavior" name="DIT.Data.DRD.Service.PIERDataService">
<endpoint address="DataService" binding="netTcpBinding" bindingConfiguration="TCPBinding_IDataService"
contract="DIT.Data.DRD.Service.IPIERDataService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="MEX" binding="mexTcpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:9100/DRDService"/>
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="DataServiceBehavior" >
<serviceDebug includeExceptionDetailInFaults="true"/>
<serviceMetadata httpGetEnabled="false"/>
<dataContractSerializer maxItemsInObjectGraph="61200000" />
<serviceThrottling maxConcurrentCalls="100"
maxConcurrentInstances="1000"/>
</behavior>
</serviceBehaviors>
</behaviors>
<diagnostics performanceCounters="Default">
<messageLogging logEntireMessage="true" logMalformedMessages="false"
logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="false" />
</diagnostics></system.serviceModel>
我的客户端在 C# 代码中具有以下设置
private DataServiceClient GetClient(string uri, int? timeout)
{
EndpointAddress endpointAddress = new EndpointAddress(new Uri(uri),
EndpointIdentity.CreateDnsIdentity("localhost"),
new System.ServiceModel.Channels.AddressHeaderCollection());
NetTcpBinding svcBinding = new NetTcpBinding();
svcBinding.Security.Mode = SecurityMode.Message;
svcBinding.Security.Message.ClientCredentialType = MessageCredentialType.Windows;
svcBinding.MaxReceivedMessageSize = 2147483647;
svcBinding.MaxBufferPoolSize = 2147483647;
svcBinding.MaxBufferSize = 2147483647;
svcBinding.MaxConnections = 10;
svcBinding.ReaderQuotas.MaxBytesPerRead = 2147483647;
svcBinding.ReaderQuotas.MaxDepth = 2147483647;
svcBinding.ReaderQuotas.MaxArrayLength = 2147483647;
svcBinding.ReaderQuotas.MaxNameTableCharCount = 2147483647;
svcBinding.ReaderQuotas.MaxStringContentLength = 2147483647;
if (timeout.HasValue)
svcBinding.SendTimeout = svcBinding.ReceiveTimeout = new TimeSpan(0, timeout.Value, 0);
else
svcBinding.SendTimeout = svcBinding.ReceiveTimeout = new TimeSpan(0, 5, 0); // this is default
PIERDataServiceClient dsc = new PIERDataServiceClient(svcBinding, endpointAddress); //this is wcf client from ClientBase
return dsc;
}
有 WCF 超时问题经验的人可以解释一下吗?我一直在尝试关注各种论坛上的无数帖子,但我收集的理解以及以代码和配置形式实现的内容并没有多大帮助。
TIA, 什拉万
I have a WCF Service exposed via TCPbinding running on a server in NY. I have no issues connecting to the service and getting back the results from clients connecting to this service from Americas but having issues for clients from London/Europe. I am not quite sure why this timeout issue happens but below are by Client and Server settings.
Server
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="TCPBinding_IDataService"
receiveTimeout="00:20:00"
openTimeout="00:05:00"
maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647"
maxConnections="10"
maxBufferSize="2147483647">
<readerQuotas maxDepth="2147483647"
maxStringContentLength="2147483647"
maxArrayLength="2147483647"
maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647"/>
<security mode="Message">
<message clientCredentialType="Windows"/>
</security>
</binding>
</netTcpBinding>
</bindings>
<services>
<service behaviorConfiguration="DataServiceBehavior" name="DIT.Data.DRD.Service.PIERDataService">
<endpoint address="DataService" binding="netTcpBinding" bindingConfiguration="TCPBinding_IDataService"
contract="DIT.Data.DRD.Service.IPIERDataService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="MEX" binding="mexTcpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:9100/DRDService"/>
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="DataServiceBehavior" >
<serviceDebug includeExceptionDetailInFaults="true"/>
<serviceMetadata httpGetEnabled="false"/>
<dataContractSerializer maxItemsInObjectGraph="61200000" />
<serviceThrottling maxConcurrentCalls="100"
maxConcurrentInstances="1000"/>
</behavior>
</serviceBehaviors>
</behaviors>
<diagnostics performanceCounters="Default">
<messageLogging logEntireMessage="true" logMalformedMessages="false"
logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="false" />
</diagnostics></system.serviceModel>
My client has the following settings in C# code
private DataServiceClient GetClient(string uri, int? timeout)
{
EndpointAddress endpointAddress = new EndpointAddress(new Uri(uri),
EndpointIdentity.CreateDnsIdentity("localhost"),
new System.ServiceModel.Channels.AddressHeaderCollection());
NetTcpBinding svcBinding = new NetTcpBinding();
svcBinding.Security.Mode = SecurityMode.Message;
svcBinding.Security.Message.ClientCredentialType = MessageCredentialType.Windows;
svcBinding.MaxReceivedMessageSize = 2147483647;
svcBinding.MaxBufferPoolSize = 2147483647;
svcBinding.MaxBufferSize = 2147483647;
svcBinding.MaxConnections = 10;
svcBinding.ReaderQuotas.MaxBytesPerRead = 2147483647;
svcBinding.ReaderQuotas.MaxDepth = 2147483647;
svcBinding.ReaderQuotas.MaxArrayLength = 2147483647;
svcBinding.ReaderQuotas.MaxNameTableCharCount = 2147483647;
svcBinding.ReaderQuotas.MaxStringContentLength = 2147483647;
if (timeout.HasValue)
svcBinding.SendTimeout = svcBinding.ReceiveTimeout = new TimeSpan(0, timeout.Value, 0);
else
svcBinding.SendTimeout = svcBinding.ReceiveTimeout = new TimeSpan(0, 5, 0); // this is default
PIERDataServiceClient dsc = new PIERDataServiceClient(svcBinding, endpointAddress); //this is wcf client from ClientBase
return dsc;
}
Can someone having experience with WCF timeout issues shed some light on this? I've been trying to follow the gzillion posts on various forums but the understanding I gathered and implementation in the form of code and configuration is not helping much.
TIA,
Shravan
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论