3

I'm using Microsoft Service Trace Viewer to check a log for an exception. Exception is:

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.

The webservice is up and running, and I can reach it fine. I'm generating several reports using methods from the same webservice, and all is fine except one. (this report has a lot of data). I'm guessing it has to do with returning too much data / timeout, but how can I examine this using Microsoft Service Trace Viewer? (I'm new at this tool).

This is my exception string:

<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>

Please help, I really got no clue here...

Gijs
  • 5,201
  • 1
  • 27
  • 42

2 Answers2

2

To try to get a more specific error, enable tracing on both the client and the service, see the links below for more information. Once you have a .svclog file, open it with the trace viewer and click on any activities highlighted in red to view details - if you're exceeding a WCF limit such as MaxReceivedMessageSize it should appear in the log for either the client or service.

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

How to turn on WCF tracing?

Community
  • 1
  • 1
Mike Payne
  • 614
  • 4
  • 4
  • Thanks for your answer. I just got som dbtables with lots of more data, and managed to reproduce the crash. It seems that is has something to do with MaxReceivedMessageSize, but from the logs I'm not sure how to verify this. I've extended my logging with the config. from "how to turn on wcf tracing" in my app.config, but I still can't see any messages in the log saying I've exceeded the MaxReceivedMessageSize. Do I need to add logging to the web.config file as well? – user1823747 Nov 15 '12 at 08:53
  • Yes, add tracing to the web.config since it could be an error on the server side. – Mike Payne Nov 15 '12 at 14:12
0

A common cause for this from what I've encountered is a DataContractSerializer exception. Usually it's a circular reference for me.

Typically what I will do is leave a commented block of code in the service somewhere that uses DataContractSerializer to manually serialize the object that is about to return. You will get a more useful message from the exception it generates.

Assuming you have a "value" variable, here is one way to accomplish the task:

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

Then I will execute the code to examine the exception.

DomenicDatti
  • 655
  • 7
  • 15