Freigeben über


The server committed a protocol violation

For the longest time I was having problems calling my WCF server, where the message in the exception I got client side was this:

"The server committed a protocol violation. Section=ResponseBody Detail=Response chunk format is invalid"

For the longest time I had no clue as to what was going on. I tried searching the web, but I found very few (only a hand full, I think) references, and none of those references seemed to make sense in my context (actually, I am hoping that this post will get indexed such that people facing the same may hit this post and maybe be helped out. I know... The good samaritan!). I tried enabling tracing, but I didn't see anything that jumped out at me. It has to be said, though, that I am by no means a master at reading those traces. I tried using Fiddler, but for some reason that caused to halt the response from my service to the client -- I still have to work out why that is. I tried with Network Monitor, but I drowned in the sea of frames it reported.

I enlisted the help of some of the people in the WCF framework team, and pretty quickly, we got some traction. The first thing that stood out was that the communication between client and the server was chunked. In the HTTP 1.1 spec, it states that if you use chunking, you (the server) has to provide the chunking length. In my case that was missing. After further input from the WCF people, the solution was very simple: Before returning the message to the client, simply clear all properties on the message (using Properties.Clear() on the message in question).

I hope this will help those of you who are unfortunate enough to run into this one.

EDIT: After talking a bit more to the people in WCF, it turns out that this is most likely expected behavior. See this MSDN article, specifically the "Working with Properties" section. Specifically, this sentence explains it:

"Normally, property values do not map directly to any part of the message on the wire, but rather provide various message processing hints to the various channels in the WCF channel stack or to the CopyTo service framework"

Comments

  • Anonymous
    January 23, 2009
    PingBack from http://blog.a-foton.ru/index.php/2009/01/23/the-server-committed-a-protocol-violation/

  • Anonymous
    January 23, 2009
    PingBack from http://blog.a-foton.ru/index.php/2009/01/23/the-server-committed-a-protocol-violation/

  • Anonymous
    January 23, 2009
    I'm getting a similar exception on one of my installations... I wonder if you might be able to point me in a direction for solving the problem... Here's the error.. The server committed a protocol violation. Section=ResponseStatusLine

  • Anonymous
    January 23, 2009
    You will have to give me a little more detail. Is this a WCF service or what? Anything you can spare will help.

  • Anonymous
    April 23, 2010
    Hi, I have a similar problem when calling an ASMX web service from my WCF service. So basically, my WCF service here is actiing as a client and calling an ASMX web service. On doing so, occassionally I get the error "The server committed a protocol violation. Section=ResponseStatusLine". Can you please help me on this one? Thanks Naeem

  • Anonymous
    April 25, 2010
    I am not sure about this one. I will check some sources... :-)

  • Anonymous
    November 14, 2010
    Hii All, Even i was facing the similar problem but some how i figured it out. Error "The server committed a protocol violation. Section=ResponseStatusLine" may be possible because of skype running on your machine as skype uses port 80 for its incoming and outgoing messages, so localhost also uses port 80 and it could not find port 80 because skype is in use. Possible solution is that, you can disable skype from using port 80. this wont be of any trouble, from skype go to tools , options, select advance and then select connection in that just uncheck port 80 option. I hope this would help someone out here thanks. Mehul Makwana.