2014-09-20 34 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>

相關問題