2

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

TIA,沙拉万

4

0 回答 0