Geeks With Blogs

@PoundingCode
  • PoundingCode And why is it we still use a floppy disk as the icon to indicate saving anything? Has anyone actual purchased on in the last 10 years?!? about 495 days ago
  • PoundingCode @bitcoinprice Trying to figure if that's better/worse than what happened to my house a few years ago... about 496 days ago

Pounding Code technological rantings and code samples

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.

http://dgoins.wordpress.com/2009/12/18/64bit-wcf-custom-isolated-%E2%80%93-rest-%E2%80%93-%E2%80%9C504%E2%80%9D-response/

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 f5abd850-ec52-401a-8bac-bcea22c74138 .biological/legal mother This item refers to the supervisor’s evaluation of the caseworker’s ability to involve the biological/legal mother in the permanency planning process. 75d8ecb7-91df-475f-aa17-26367aeb8b21 false true Admin account 2010-01-06T17:58:24.88 1.20 764a2333-f445-4793-b54d-1c3084116daa

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.

Posted on Wednesday, March 9, 2011 12:51 PM WCF , Fiddler | Back to top


Comments on this post: wcf http 504: Working on a mystery

# re: wcf http 504: Working on a mystery
Requesting Gravatar...
This post really helped me out.

As you wrote, I had been digging through several blog posts about this strange 504 error. Turning on tracing really helped me out, since none of the suggested solutions in the other blogs worked for me.

In my case the error occured when I didnt include the datetime property in my test data, using JSON Serialization.

Again, big thanks for this post!
Left by Johan Mannerqvist on Jun 05, 2011 6:39 AM

# re: wcf http 504: Working on a mystery
Requesting Gravatar...
Hi,
Great, this helped me a lot.
Actually I activated tracing and the message was quite clear: serialization exception.
You made me save a lot of time, thx.
Left by acsed on Sep 12, 2011 8:11 AM

# Your Post Sent Me Down The Right Path
Requesting Gravatar...
DataView has a serialization issue. I solved the problem by returning a DataTable instead.
Left by Nathaniel on Feb 09, 2012 3:00 PM

# re: wcf http 504: Working on a mystery
Requesting Gravatar...
Yes indeedy this was helpful.

Beat my head bloody before I found this.

I love the philosophy of hiding errors unless you turn on tracing. I also love it when the debugger lies to me. IMPLICIT, hidden serialization is a great idea. I had a gut feeling the problem was in the serialization, but no way to know for sure.

Debugger: "return foo;" SUCCESS!

Browser: "error"

Me: #$@$!!! !@#$ %! @!!! %#%%$ %#$%@#$ MICROSOFT!!!
Left by jeffa on Oct 16, 2012 3:15 PM

# re: wcf http 504: Working on a mystery
Requesting Gravatar...
It is a super helpful post.

I have resolved my issues by enable WCF Tracing.

Thanks a lot!
Left by Shawn.Ray on Jan 06, 2013 10:52 PM

# re: wcf http 504: Working on a mystery
Requesting Gravatar...
thank you!
Left by Stuart on May 16, 2013 4:40 PM

# re: wcf http 504: Working on a mystery
Requesting Gravatar...
Excellent Post! Thanks so much!
Left by Lana on May 31, 2013 5:21 AM

# re: wcf http 504: Working on a mystery
Requesting Gravatar...
Thank you for this, I'd spent hours going over IIS, fiddler and other trace logs trying to figure out where the actual exception was.
Left by Nathan on Jul 02, 2013 10:06 AM

# re: wcf http 504: Working on a mystery
Requesting Gravatar...
Thanks man, helped me a lot!
Left by Paul on Aug 08, 2013 1:09 AM

# re: wcf http 504: Working on a mystery
Requesting Gravatar...
Hi, My issue not yet solved. I am using stream to get the response. But still my data get disappear when it moves from server to client.
Stream responseStream = serviceResponse.GetResponseStream();
TextReader txtReader = new StreamReader(responseStream);
response.Output = txtReader.ReadToEnd();
Left by Selvakumar on Sep 27, 2013 4:42 PM

# re: wcf http 504: Working on a mystery
Requesting Gravatar...
Did you activated tracing verify that the exception is on the server? If the server is not throwing an error that it is swallowing? Your next step would be to see if a message is coming back to the client using Fiddler, etc.
Left by James Fleming on Sep 28, 2013 10:48 AM

Your comment:
 (will show your gravatar)
 


Copyright © James Fleming | Powered by: GeeksWithBlogs.net | Join free