Welcome to Professional ASP.NET - Chris Love's Official Blog Sign in | Join | Help

Chris Love's Official ASP.NET Blog

Chris Love's Helpful tips, tricks and pragmatic development knowledge for the ASP.NET world.
ASP Insider

Microsoft Store

ReadResponse() failed: The server did not return a response for this request.

If you have found this Blog entry most likely you are seeing this response in Fiddler. It is accompanied by an HTTP status code of 504. ReadResponse() failed: The server did not return a response for this request is not very helpful and in fact fairly useless in debugging the problem, well short of looking up the exact phrase on Bing or Google to find this blog :).

Fiddler Good Response

Successful Response


Fiddler ReadResponse() failed

ReadResponse() failed

I hit this error when trying to return an extremely large set of records via a WCF service today. In fact back at the New York City Code Camp I was asked if WCF could serialize a large dataset into JSON and I started playing at the time. I had sort of forgot about this over the past few months.

Diagnosing the problem involved turning on WCF Tracing and verifying my suspicion that I had hit a default limit. Well the WCF DataContractSerializer has a limit of 65536 object in the object graph. So I did the match on my demo data I was using to work through this issue and yes, I was over that limit in the number of objects. I had a 13 property object and crossing the 5041 record limit caused this issue to surface.

Now back to the ReadResponse() failed issue when using Fiddler. This is my suspicion at this point, so take it for what it’s worth. Based on things I read Fiddler creates this error message in response to a network error, hence the HTTP 504 status code, which is NOT an IIS generated code. It is actually a proxy generated status code and since Fiddler is a proxy this is why you get a 504.

My deduction is the large record set pushes some sort of limit on the network packets and an end of file is missing. Hence Fiddler cannot complete processing of the file stream coming in and promptly throws the proxy error.

Now, how do you deal with large sets of data in the context of JSON, AJAX, WCF, jQuery, etc? Well my suggestion is you don’t. Yes I said it, you don’t. Here is my rational. If you intend to page, sort and filter data in the browser you are wasting your time. It is NOT designed to do this. Yes you can do all that with great performance for small, reasonable sizes of data. But databases were designed to perform these tasks on data, not a JavaScript array sorting algorithm. Instead drive your users to define a much better set of criteria to narrow down the result set. This will give you the ability to reduce the to a manageable size.

I guess how you limit your set of data is up to you. Two strategies that I like are checking the potential size and throwing a ThisIsNotGoingToHappenException to the user so you can let them know they need to do something more to limit the results more. The next is limiting the results to say 500 or 1000 or some other manageable arbitrary size of your choosing and letting the user know there might be more. Either way I think its a good idea to let the user know there is more available, just be more specific. Of course you will have to give them a way to reduce the set.

If you are not having an issue with large responses being sent from the server and you still get the ReadResponse failed error from Fiddler, there is most likely something that is causing a corrupt stream to be sent from the server to the client, Fiddler in this case.


Posted: Wednesday, September 01, 2010 11:01 PM

by Chris Love
Filed under: , , ,

Comments

Chris Love's Official ASP.NET Blog said:

Yesterday I posted an entry on dealing with larger result sets that cause Fidder to create a ReadResponse()

# September 2, 2010 9:06 AM

Marc Roussel said:

"... checking the potential size and throwing a ThisIsNotGoingToHappenException to the user " This is a good one but how do you check the size of something against the MaxBufferSize limit which actually is the maximum possible Let say you ahve a ObservableCollection to return, how is it code so you can know the size of this which relates to the maxBuffersize setting
# February 14, 2011 11:09 AM

C van Dijk said:

My suspicion is that this error is caused by a timeout, which is triggered in Fiddler. I've several times faced this same error, in different use cases. You can reproduce this behaviour by sending a simple get request to a server and break the response, by: 1) Debug at the point where data is received, for example in event OnReadResponseBuffer; 2) Performing expensive operations within event OnReadResponseBuffer. In both cases, let the proxy running, don't debug this thread. The funny thing is when you shutdown the pipe by setting the flag abortreading. No response whatsoever and no errors. Maybe there is an option to set the timeout internal. Anyway, you could stop scraping when there are expensive operations within OnReadResponseBuffer, which is the method on top of the stack when the error occurs. This way, the stream will be successfully received and no errors are shown. Also, by debugging fiddlercore in asm, there are conditional statements performed with the timers. So again, this probably triggered the error, imho.
# June 6, 2011 12:37 PM
Leave a Comment

(required) 

(required) 

(optional)

(required) 

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS