2012-11-14 74 views
3

我正在使用Microsoft服務跟蹤查看器檢查日誌以查找異常。例外是:需要幫助瞭解Microsoft服務跟蹤查看器日誌

An error occurred while receiving the HTTP response to ...someservice.svc. 
This could be due to the service endpoint binding not using the HTTP protocol. 
This could also be due to an HTTP request context being aborted by the server 
(possibly due to the service shutting down). See server logs for more details. 

該web服務已啓動並運行,我可以達到它的罰款。我使用來自同一web服務的方法生成了幾個報告,除了一個以外,一切都很好。 (這份報告有很多數據)。我猜它與返回太多的數據/超時有關,但我如何使用Microsoft Service Trace Viewer來檢查這個問題? (我是這個工具的新手)。

這是我的異常字符串:

<ExceptionString>System.ServiceModel.CommunicationException: An error occurred 
while receiving the HTTP response to http://someservice.svc. This could be due 
to the service endpoint binding not using the HTTP protocol. This could also 
be due to an HTTP request context being aborted by the server (possibly due to 
the service shutting down). See server logs for more details. ---> 

System.Net.WebException: The underlying connection was closed: An unexpected 
error occurred on a receive. ---> 

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.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.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout) 
    --- End of inner exception stack trace ---</ExceptionString> 

請幫幫忙,我真的來到這裏不知道......

回答

2

,試圖獲得一個更具體的錯誤,啓用跟蹤同時在客戶端和服務,請參閱下面的鏈接瞭解更多信息。一旦你有一個.svclog文件,用跟蹤查看器打開它,點擊紅色突出顯示的任何活動以查看詳細信息 - 如果超出了WCF限制(如MaxReceivedMessageSize),它應該出現在客戶端或服務的日誌中。

http://msdn.microsoft.com/en-us/library/ms733025.aspx

How to turn on WCF tracing?

+0

感謝您的回答。 我剛剛拿到了很多更多數據的som dbtables,並設法重現崩潰。這似乎與MaxReceivedMessageSize有關,但是從日誌中我不確定如何驗證這一點。我已經使用配置擴展了日誌記錄。從我的app.config中「如何打開wcf跟蹤」,但我仍然看不到日誌中的任何消息,說我已經超過了MaxReceivedMessageSize。我是否還需要將日誌記錄添加到web.config文件中? – user1823747

+0

是的,添加跟蹤web.config,因爲它可能是服務器端的錯誤。 –

0

這樣做的一個常見原因,從以前遇到過什麼,我是一個DataContractSerializer的例外。通常這是我的循環參考。

通常我會做的是在服務某處使用DataContractSerializer手動序列化即將返回的對象的代碼塊。您將從它生成的異常中獲得更有用的消息。

假設你有一個「值」變量,這裏是完成任務的一種方法:

var xs = new DataContractSerializer(value.GetType()); 
var ms = new MemoryStream(); 
xs.WriteObject(ms, value); 

然後,我將執行代碼以檢查異常。