2010-12-11 88 views
1

我剛剛創建了一個WCF服務庫。我創建了一個測試函數,並且我從WCF測試客戶端調用了測試函數。我在代碼中放了一個斷點。控制到達中斷點並停在那裏。現在我讓控制器停留在某個時間點的斷點處,並在大約一分鐘時間內收到以下錯誤消息WCF顯示超時錯誤

「無法調用服務可能的原因:服務處於脫機狀態或無法訪問;客戶端配置與代理不匹配;現有代理無效,請參閱堆棧跟蹤以瞭解更多詳細信息,您可以嘗試通過啓動新代理,恢復爲默認配置或刷新服務來恢復。

錯誤詳細信息: 請求通道在等待00:00:59.9843750後的回覆時超時。增加傳遞給請求調用的超時值或增加綁定上的SendTimeout值。分配給此操作的時間可能是超時時間的一部分。

服務器堆棧跟蹤: 在System.ServiceModel.Channels.RequestChannel.Request(消息消息,時間跨度超時) 在System.ServiceModel.Channels.ClientReliableChannelBinder 1.RequestClientReliableChannelBinder 1.OnRequest(TRequestChannel信道,消息的消息,時間跨度超時,MaskingMode maskingMode) 在System.ServiceModel.Channels.ClientReliableChannelBinder 1.Request(Message message, TimeSpan timeout, MaskingMode maskingMode) at System.ServiceModel.Channels.ClientReliableChannelBinder 1.Request(消息消息,時間跨度超時) 在System.ServiceModel.Security.SecuritySessionClientSettings`1.SecurityRequestSessionChannel.Request(消息消息,時間跨度超時) 在System.ServiceModel。 Dispatcher.RequestChannelBinder.Request(消息消息,TimeSpan超時) at System.ServiceModel.Chan nels.ServiceChannel.Call(String action,Boolean oneway,ProxyOperationRuntime operation,Object [] ins,Object [] outs,TimeSpan timeout) at System.ServiceModel.Channels.ServiceChannel.Call(String action,Boolean oneway,ProxyOperationRuntime operation,Object []插件,在System.ServiceModel.Channels.ServiceChannelProxy.Invoke(即時聊天消息)在

異常重新拋出對象[]奏) 在System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage包括methodCall,ProxyOperationRuntime操作) [ 0]: at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg,IMessage retMsg) at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData & msgData,Int32類型) at ITrustmarkService.StartRobotProcess() at TrustmarkServiceClient.StartRobotProcess()

任何想法是什麼造成這種情況?

回答

2

這是MSDN樣本WCF客戶端配置:

<bindings> 
      <wsHttpBinding> 
       <binding name="WSHttpBinding_ISampleService" closeTimeout="00:01:00" 
        openTimeout="00:01:00" receiveTimeout="00:01:00" sendTimeout="00:01:00" 
        bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" 
        maxBufferPoolSize="524288" maxReceivedMessageSize="65536" 
        messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" 
        allowCookies="false"> 
        <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" 
         maxBytesPerRead="4096" maxNameTableCharCount="16384" /> 
        <reliableSession ordered="true" inactivityTimeout="00:10:00" 
         enabled="false" /> 
        <security mode="Message"> 
         <transport clientCredentialType="None" proxyCredentialType="None" 
          realm="" /> 
         <message clientCredentialType="Windows" negotiateServiceCredential="true" 
          algorithmSuite="Default" establishSecurityContext="true" /> 
        </security> 
       </binding> 
      </wsHttpBinding> 
     </bindings> 

你應該設置receiveTimeoutsendtimout到挪用值,你可以看到在您的測試的配置文件類似的配置。

+0

@Sidharth要完全正確,你需要設置[binding.receiveTimeout](https:// msdn.microsoft.com/en-us/library/system.servicemodel.channels.binding.receivetimeout(v=vs.110).aspx)以及[binding.ReliableSession.InactivityTimeout](https://msdn.microsoft。 com/en-us/library/system.servicemodel.reliablesession.inactivitytimeout(v = vs.110).aspx),因爲這兩個過期的任何一個都會關閉連接。這兩個設置都可以在.config文件中進行更改,如上所述,或者在代碼中進行更改。 – AlwaysLearning 2017-09-28 04:48:33

0

是的。默認情況下,WCF服務的響應超時爲1分鐘。這意味着客戶可以等待一分鐘,如果他們在那段時間內沒有得到迴應,他們可以假設失敗/沒有迴應。

在你的情況下,你正在使用一個斷點來保存WCF服務來響應客戶端的請求。等待一分鐘後,客戶端超時,不再等待。

您可以從WCF服務的.config文件中增加此超時。

+0

你能告訴我可以在.config文件中更改它嗎? – Sidharth 2010-12-11 06:39:42

+0

http://stackoverflow.com/questions/424358/increasing-the-timeout-value-in-a-wcf-service – decyclone 2010-12-11 07:14:59