我們有一個WCF服務(BasicHttpBinding),它在30秒後總是失敗。 30秒內通話完成,沒有錯誤。任何超過30秒就會失敗,一個502錯誤網關例外:WCF服務調用總是在30秒後失敗(502)Bad Gateway
System.Net.WebException: The remote server returned an error: (502) Bad Gateway.
但尚未WCF調用繼續在後臺運行(並最終完成)。我們已經確認BasicHttpBinding - 綁定 - sendTimeout(在web.config中)大於30秒(實際上設置爲5分鐘)。我們在客戶端和服務器上都確認了這一點。
以下是完整的堆棧跟蹤:
System.ServiceModel.ProtocolException: The remote server returned an unexpected response: (502) Bad Gateway. ---> System.Net.WebException: The remote server returned an error: (502) Bad Gateway.
at System.Net.HttpWebRequest.GetResponse()
at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
--- End of inner exception stack trace ---
Server stack trace:
at System.ServiceModel.Channels.HttpChannelUtilities.ValidateRequestReplyResponse(HttpWebRequest request, HttpWebResponse response, HttpChannelFactory factory, WebException responseException, ChannelBinding channelBinding)
at System.ServiceModel.Channels.HttpChannelFactory.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.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)
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)
哪裏這個30秒「超時」是來自或爲什麼會返回一個502錯誤網關錯誤任何想法?
解決方案: 我們正在使用具有自己的代理設置的IIS7應用程序請求路由模塊。代理服務器設置的默認超時時間爲30秒。將這個增加到600秒(10分鐘)解決了我們的問題。錯誤的網關錯誤並不完全正確,但WCF跟蹤查看器(請參閱答案)幫助瞭解問題不是服務本身,而是客戶端和wcf服務之間的問題。
我們已經嘗試增加closeTimeout,openTimeout和receiveTimeout到5分鐘(在客戶端和服務器上)並仍然看到問題。 – 2010-05-04 15:20:14
感謝有關WCF服務跟蹤查看器的信息。我用它來收集客戶端和服務器上的跟蹤信息,但我從中看到服務器正在正常完成,但客戶端以「接收到錯誤的HTTP響應」結束,內部消息是「遠程服務器返回一個意外的迴應:(502)壞門戶。「服務器在42秒後完成,客戶端在31秒時收到錯誤。客戶端總是31秒。 – 2010-05-05 18:42:45
想通了。我們使用具有代理設置的IIS7應用程序請求路由模塊,其中一個是30秒超時。使用WCF服務跟蹤查看器的確幫助我理解WCF服務不是問題,而是客戶端與服務之間的問題。 – 2010-05-05 20:07:16