wcf http 504: Working on a mystery
Posted
by James Fleming
on Geeks with Blogs
See other posts from Geeks with Blogs
or by James Fleming
Published on Wed, 09 Mar 2011 17:51:35 GMT
Indexed on
2011/03/10
0:11 UTC
Read the original article
Hit count: 529
Ok,
So you're here because you've been trying to solve the mystery of why you're getting a 504 error. If you've made it to this lonely corner of the Internet, then the advice you're getting from other bloggers isn't the answer you are after. It wasn't the answer I needed either, so once I did solve my problem, I thought I'd share the answer with you.
For starters, if by some miracle, you landed here first you may not already know that the 504 error is NOT coming from IIS or Casini, that response code is coming from Fiddler.
HTTP/1.1 504 Fiddler - Receive Failure
Content-Type: text/html
Connection: close
Timestamp: 09:43:05.193
ReadResponse() failed: The server did not return a response for this request.
The take away here is Fiddler won't help you with the diagnosis and any further digging in that direction is a red herring.
Assuming you've dug around a bit, you may have arrived at posts which suggest you may be getting the error because you're trying to hump too much data over the wire, and have an urgent need to employ an anti-pattern: due to a special case: http://delphimike.blogspot.com/2010/01/error-504-in-wcfnet-35.html
Or perhaps you're experiencing wonky behavior using WCF-CustomIsolated Adapter on Windows Server 2008 64bit environment, in which case the rather fly MVP Dwight Goins' advice is what you need.
For me, none of that was helpful.
I could perform a get on a single record http://localhost:8783/Criterion/Skip(0)/Take(1)
but I couldn't get more than one record in my collection as in:
http://localhost:8783/Criterion/Skip(0)/Take(2)
I didn't have a big payload, or a large number of objects (as you can see by the size of one record below)
-
A-1B
So while I was able to retrieve one record without a hitch (thus the record above) I wasn't able to return multiple records. I confirmed I could get each record individually, (Skip(1)/Take(1))so it stood to reason the problem wasn't with the data at all, so I suspected a serialization error.
The first step to resolving this was to enable WCF Tracing. Instructions on how to set it up are here: http://msdn.microsoft.com/en-us/library/ms733025.aspx. The tracing log led me to the solution.
The use of type 'Application.Survey.Model.Criterion' as a get-only collection is not supported with NetDataContractSerializer. Consider marking the type with the CollectionDataContractAttribute attribute or the SerializableAttribute attribute or adding a setter to the property.
So I was wrong (but close!). The problem was a deserializing issue in trying to recreate my read only collection. http://msdn.microsoft.com/en-us/library/aa347850.aspx#Y1455
So looking at my underlying model, I saw I did have a read only collection. Adding a setter was all it took.
public virtual ICollection<string> GoverningResponses
{
get
{
if (!string.IsNullOrEmpty(GoverningResponse))
{
return GoverningResponse.Split(';');
}
else
return null;
}
}
Hope this helps. If it does, post a comment.
© Geeks with Blogs or respective owner