Dec 5 2006

WCF and large messages

Category: IT Related | .NetRory Primrose @ 06:11

I am getting some interesting results when messages are returned from a WCF service. Small responses come through fine. When the responses start to get large, I run into the QuotaExceededException exception. This is fine because you can increase the MaxReceivedMessageSize configuration value on the client endpoint. This starts to fail when the size of the data continues to increase and eventually I get the exception WebException: The underlying connection was closed: The connection was closed unexpectedly.

The service call is still being made (I can debug it), but it seems that the error is coming back quick enough that it is a problem with the server endpoint, rather than client endpoint or configuration on the client.

Anyone come across this before???

Tags:

Comments (3) -

1.
Rory Primrose Rory Primrose says:

Tracing is cool. Here is the answer:

The InnerException message was 'Maximum number of items that can be serialized or deserialized in an object graph is '65536'. Change the object graph or increase the MaxItemsInObjectGraph quota. '.  Please see InnerException for more details.

In the trace log, this is followed by "RequestContext aborted" and "Failed to send response message over HTTP".

2.
Ciaran O'Neill Ciaran O'Neill Ireland says:

Hi Rory,

I've just stumbled upon your blog while trying to debug an error I'm getting. I'm also getting the error: "There was an error while trying to serialize parameter http://tempuri.org/:batch. The InnerException message was 'Maximum number of items that can be serialized or deserialized in an object graph is '65536'. Change the object graph or increase the MaxItemsInObjectGraph quota. '. Please see InnerException for more details.".

However, my object graph configuration is set to: <dataContractSerializer maxItemsInObjectGraph="2147483647"/>

Did you ever get around this problem?  Any help is appreciated.

Thanks,
Ciaran O'Neill

3.
Rory Primrose Rory Primrose Australia says:

Hi Ciaran,

I don't know why your configuration is not working. I would have to do a bit of reading. However, there is a better fix to the problem.

Essentially this is a service contract design issue. I prefer to design service contracts such that service configuration and (most importantly) client configuration doesn't need anything out of the ordinary to consume the service.

Large message sizes and messages with a large object graph mean that the service contract should be redesigned. This usually results in a more chatty service design.

I try to write a blog post about this today to flesh this out in more detail.

Add comment

  Country flag

biuquote
  • Comment
  • Preview
Loading