针对LN中客户端的netTCPBinding超时的WCF服务,适用于美国的客户端

时间:2010-12-15 20:42:56

标签: wcf timeout nettcpbinding

我通过在纽约的服务器上运行的TCPbinding公开了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超时问题经验的人可以对此有所了解吗?我一直试图在各种论坛上关注gzillion的帖子,但我收集的理解以及代码和配置形式的实现并没有多大帮助。

TIA, Shravan

0 个答案:

没有答案