2014-09-20 60 views
0

我有一个WCF客户端应用程序,它将数据传输到一个大的.Net集合(25 MB)的第三方供应商。WCF客户端在向第三方发送大量数据时发生数据超时

客户端总是超时,但供应商的服务一直运行完成。

我需要客户端从供应商服务获得回应,以便我可以继续下一个集合。

我在客户端应用程序的开头部署了以下代码,但它仍然没有好处。我得到相同的结果。

serviceClient” 是我的客户端应用程序和 “hhOutBoundClient” 是供应商的服务。

ShopProcessService.ShopProcessServiceClient serviceClient = new ShopProcessService.ShopProcessServiceClient(); 

      HHOutBoundService.RyderServiceClient hhOutBoundClient = new HHOutBoundService.RyderServiceClient(); 

      var customBinding = new CustomBinding(serviceClient.Endpoint.Binding); 
      var transportElement = customBinding.Elements.Find<HttpTransportBindingElement>(); 
      transportElement.KeepAliveEnabled = true; 
      serviceClient.Endpoint.Binding = customBinding; 

可有人请告诉我如何保持会话处于活动为我的客户,这样就不会超时?

这是我的客户端配置文件。矿是与wsHttpBinding之一。

<system.serviceModel> 
     <bindings> 
      <basicHttpBinding> 
       <binding name="BasicHttpBinding_RyderService" closeTimeout="02:00:00" 
        openTimeout="02:00:00" receiveTimeout="02:00:00" sendTimeout="02:00:00" 
        allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" 
        maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" 
        textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true" 
        messageEncoding="Text"> 
        <readerQuotas maxDepth="32" maxStringContentLength="2147483647" 
         maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" /> 
        <security mode="Transport"> 
         <transport clientCredentialType="Basic" proxyCredentialType="None" 
          realm="" /> 
         <message clientCredentialType="UserName" algorithmSuite="Default" /> 
        </security> 
       </binding> 
      </basicHttpBinding> 
      <wsHttpBinding> 
       <binding name="WsHttpBinding_IShopProcessService" closeTimeout="02:00:00" 
        openTimeout="02:00:00" receiveTimeout="02:00:00" sendTimeout="02:00:00" 
        maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"> 
        <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" 
         maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" /> 
        <security mode="None" /> 
       </binding> 
       <binding name="WSHttpBinding_IShopProcessService"> 
        <security mode="None" /> 
       </binding> 
      </wsHttpBinding> 
     </bindings> 
     <diagnostics wmiProviderEnabled="true"> 
      <messageLogging logMessagesAtTransportLevel="true" logMessagesAtServiceLevel="true" logMalformedMessages="true" logEntireMessage="true" maxSizeOfMessageToLog="2147483647" maxMessagesToLog="100" /> 
     </diagnostics> 
     <client> 
      <endpoint address="https://abc.xyz.com/RyderDataPortal/RyderService.svc" 
       behaviorConfiguration="BasicHttpBinding_RyderService" binding="basicHttpBinding" 
       bindingConfiguration="BasicHttpBinding_RyderService" contract="HHOutBoundService.IRyderService" 
       name="BasicHttpBinding_RyderService" /> 
      <endpoint address="http://999.999.9.999/RyderShopProcessService/ShopProcessService.svc" 
       binding="wsHttpBinding" bindingConfiguration="WsHttpBinding_IShopProcessService" 
       contract="ShopProcessService.IShopProcessService" name="WsHttpBinding_IShopProcessService" /> 
     </client> 
     <behaviors> 
      <endpointBehaviors> 
       <behavior name="WsHttpBinding_IShopProcessService"> 
        <dataContractSerializer maxItemsInObjectGraph="2147483647"/> 
       </behavior> 
       <behavior name="webhttp"> 
        <webHttp/> 
       </behavior> 
       <behavior name="BasicHttpBinding_RyderService"> 
        <dataContractSerializer maxItemsInObjectGraph="2147483647"/> 
       </behavior> 
      </endpointBehaviors> 
     </behaviors> 
    </system.serviceModel> 

我已经从在结合上述源代码在所述客户端的结合,反之亦然设置ReliableMessaging的属性试过各种方法;它没有任何作用。

我非常感谢以前经历过这样的人,并提出了一个明确的解决方案。

在此先感谢。

确切错误消息:

Message: { strMessage = Class: ShopProcessServiceClient 
Method: Main 
Error: The underlying connection was closed: A connection that was expected to be kept alive was closed by the server. 
InnerException: System.Net.WebException: The underlying connection was closed: A connection that was expected to be kept alive was closed by the server. ---> System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host 
    at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags) 
    at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size) 
    --- End of inner exception stack trace --- 
    at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size) 
    at System.Net.FixedSizeReader.ReadPacket(Byte[] buffer, Int32 offset, Int32 count) 
    at System.Net.Security._SslStream.StartFrameHeader(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest) 
    at System.Net.Security._SslStream.StartReading(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest) 
    at System.Net.Security._SslStream.ProcessRead(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest) 
    at System.Net.TlsStream.Read(Byte[] buffer, Int32 offset, Int32 size) 
    at System.Net.PooledStream.Read(Byte[] buffer, Int32 offset, Int32 size) 
    at System.Net.Connection.SyncRead(HttpWebRequest request, Boolean userRetrievedStream, Boolean probeRead) 
    --- End of inner exception stack trace --- 
    at System.Net.HttpWebRequest.GetResponse() 
    at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout) 
Source: mscorlib 
StackTrace: 
Server stack trace: 
    at System.ServiceModel.Channels.HttpChannelUtilities.ProcessGetResponseWebException(WebException webException, HttpWebRequest request, HttpAbortReason abortReason) 
    at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout) 
    at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout) 
    at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout) 
    at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout) 
    at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation) 
    at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message) 

Exception rethrown at [0]: 
    at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) 
    at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) 
    at Ryder.ShopProcessService.Outbound.HHOutBoundService.IRyderService.PostFuelTankConversionCharts(TankConversionChartCollection conversion_charts) 
    at Ryder.ShopProcessService.Outbound.HHOutBoundService.RyderServiceClient.PostFuelTankConversionCharts(TankConversionChartCollection conversion_charts) in c:\Development\SMO_VS_2013\HHOutboundClient\SOASolutionA\Ryder.ShopProcessService.Outbound\Service References\HHOutBoundService\Reference.cs:line 2856 
    at Ryder.ShopProcessService.Outbound.ShopProcessServiceClient.Main(String[] args) in c:\Development\SMO_VS_2013\HHOutboundClient\SOASolutionA\Ryder.ShopProcessService.Outbound\ShopProcessServiceClient.cs:line 87, strProject = Ryder.ShopProcessService.Outbound, strRemedyTktResponse = INC000000091926 } 

Extended Properties: 
+0

的就是你得到的超时消息? TCP选项是绑定的吗? – PatFromCanada 2014-09-20 14:53:01

+0

这必须使用wsHttpBinding完成。这个消息通常表示客户必须被强制关闭,因为连接不能保持打开等等。 – sagesky36 2014-09-20 23:44:52

+0

为什么你认为这是超时?在处理特定位数的数据时可能会出错,这有帮助吗? http://stackoverflow.com/questions/7209823/an-existing-connection-was-forcibly-closed-by-the-remote-host-wcf – PatFromCanada 2014-09-21 14:55:38

回答

1

你必须增加发送超时。

<binding name="BasicHttpBinding_RyderService" sendTimeout="20:00:00" closeTimeout="02:00:00" 
        openTimeout="02:00:00" receiveTimeout="02:00:00" 
        allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" 
        maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" 
        textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true" 
        messageEncoding="Text"> 

serviceClient.Endpoint.Binding = customBinding; 
serviceClient.Endpoint.Binding.SendTimeout = new TimeSpan(0, 25, 0); 
+0

我知道从我的客户端获取数据并将数据从我的客户端发送到服务供应商只需要1.5小时。所以,我不认为增加发送时间到20小时就足够了。 2小时应该够了。你不同意吗? – sagesky36 2014-09-20 23:42:30

+0

亚1h 45min就够了。 – 2014-09-21 17:54:15

0

在WCF无论是客户端可以像影响会话超时设置。 我的意思是无论是在客户端Web.config中设置超时,请参阅:


<bindings> <wsHttpBinding> <binding name="WSHttpBinding_I" maxReceivedMessageSize="2000000" sendTimeout="[some value]"/> </wsHttpBinding> </bindings>

相关问题