Re: The server committed a protocol violation
- From: "John Spaith [MS]" <jspaith@xxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 13 Jul 2006 13:05:56 -0700
Hmm - this is very odd and is the first I've ever heard of this problem.
Your capture is quite helpful though
Request ->
GET /DMS/Installation%20Manual.htm HTTP/1.1
[snip...]
Response ->
HTTP/1.0 401 Unauthorized
[snip...]
Content-Type: text/html
Content-Length: 81
Request ->
GET /DMS/Installation%20Manual.htm HTTP/1.1
Authorization: Basic UEZFOnZpc2lvbg==
[snip...]
Response ->
[here's problem!]<B>Access denied.</B><P>Client does not have access to
the resource on the serverHTTP/1.0 200 OK
Date: Tue, 11 Jul 2006 20:55:59 GMT
Connection: keep-alive
It looks like what's happening is that the client is not reading the
content-length: 81 <B> Access denied</B> from the first request, but is
instead sending a new request right away. When it calls recv() again the
first bytes it gets back are not the "200 OK" I get because I like your
password but instead the old crusty data.
I'm not at all familiar with the .Net stuff so I don't know what they're
doing or if you could do something differently, like req.RecvBody()? You
may have to try one of their newsgroups (feel free to cross-post your new
thrd to this one though because I'm extremely curious as to what's happening
here). One potential gotcha here is that the web server does one send() for
HTTP headers and then another send() for the body, whereas IIS may optimize
this into one send() for both headers+body for a small body request like
this.
--
John Spaith
Development Lead, Windows CE
Microsoft Corporation
Check out the CE Networking Team Blog at http://blogs.msdn.com/cenet/.
This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use. © 2006 Microsoft Corporation. All rights
reserved.
"Kris Mattheus" <KMAT@xxxxxxxxxx> wrote in message
news:%23ECnt4apGHA.1592@xxxxxxxxxxxxxxxxxxxxxxx
A little background:
I've been using web services successfully for a while now. My web server
is a Windows CE 4.2 device
and my client is a windows C# application created with Visual Studio 2003.
My web server has both
NTLM and Basic authentication. By providing the Credentials for my web
service call, my
application can access the web service without any problems.
The problem:
I recently created a new application with Visual Studio 2005 using the
same logic. However, when I
try to call the web service, I get a WebException with following message:
"The server committed a protocol violation. Section=ResponseStatusLine"
As soon as I disable the authentication on the web server, the web service
call executes without
problems.
To pin-point my problem, I've created a simple test application which
merely requests a web page
from the CE device. This test application gives the same error. Here's the
code:
HttpWebRequest myWebRequest =
WebRequest.Create("http://150.158.204.40/DMS/Installation Manual.htm")
as HttpWebRequest;
NetworkCredential networkCredential = new NetworkCredential("Test",
"service");
myWebRequest.Credentials = networkCredential;
try
{
WebResponse myWebResponse = myWebRequest.GetResponse();
MessageBox.Show(myWebResponse.ContentLength.ToString());
}
catch (WebException wex)
{
Trace.WriteLine(string.Format("Caught Exception: {0}", wex.Message));
Trace.WriteLine(string.Format("Stack: {0}", wex.StackTrace));
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
I've enabled Network Tracing for this test application and I got following
output (using Basic
authentication):
System.Net Verbose: 0 : [4952]
WebRequest::Create(http://150.158.204.40/DMS/Installation Manual.htm)
System.Net Verbose: 0 : [4952]
HttpWebRequest#63840421::HttpWebRequest(http://150.158.204.40/DMS/Installation
Manual.htm#1606441202)
System.Net Verbose: 0 : [4952] Exiting
HttpWebRequest#63840421::HttpWebRequest()
System.Net Verbose: 0 : [4952] Exiting WebRequest::Create() ->
HttpWebRequest#63840421
System.Net Verbose: 0 : [4952] HttpWebRequest#63840421::GetResponse()
System.Net Information: 0 : [4952] Associating HttpWebRequest#63840421
with ServicePoint#54246671
System.Net Information: 0 : [4952] Associating Connection#25181126 with
HttpWebRequest#63840421
System.Net Information: 0 : [4952] Associating HttpWebRequest#63840421
with ConnectStream#59408853
System.Net Information: 0 : [4952] HttpWebRequest#63840421 - Request: GET
/DMS/Installation%20Manual.htm HTTP/1.1
System.Net Information: 0 : [4952] ConnectStream#59408853 - Sending
headers
{
Host: 150.158.204.40
Connection: Keep-Alive
}.
System.Net Information: 0 : [4952] Connection#25181126 - Received status
line: Version=1.0,
StatusCode=401, StatusDescription=Unauthorized.
System.Net Information: 0 : [4952] Connection#25181126 - Received headers
{
Date: Tue, 11 Jul 2006 20:55:59 GMT
Connection: keep-alive
Server: Microsoft-WinCE/4.20
WWW-Authenticate: NTLM,Basic realm="Microsoft-WinCE"
Content-Type: text/html
Content-Length: 81
}.
System.Net Information: 0 : [4952]
ConnectStream#56152722::ConnectStream(Buffered 81 bytes.)
System.Net Information: 0 : [4952] Associating HttpWebRequest#63840421
with ConnectStream#56152722
System.Net Information: 0 : [4952] Associating HttpWebRequest#63840421
with HttpWebResponse#43844556
System.Net Warning: 0 : [4952] HttpWebRequest#63840421::() - Resubmitting
request.
System.Net Information: 0 : [4952] Associating HttpWebRequest#63840421
with ServicePoint#54246671
System.Net Information: 0 : [4952] Associating Connection#25181126 with
HttpWebRequest#63840421
System.Net Information: 0 : [4952] Associating HttpWebRequest#63840421
with ConnectStream#26847985
System.Net Information: 0 : [4952] HttpWebRequest#63840421 - Request: GET
/DMS/Installation%20Manual.htm HTTP/1.1
System.Net Information: 0 : [4952] ConnectStream#26847985 - Sending
headers
{
Authorization: Basic UEZFOnZpc2lvbg==
Host: 150.158.204.40
Connection: Keep-Alive
}.
System.Net Error: 0 : [4952] Exception in the HttpWebRequest#63840421:: -
The server committed a
protocol violation. Section=ResponseStatusLine
System.Net Error: 0 : [4952] Exception in the
HttpWebRequest#63840421::EndGetResponse - The server
committed a protocol violation. Section=ResponseStatusLine
A first chance exception of type 'System.Net.WebException' occurred in
System.dll
When I look with Ethereal, I get following stream:
Request ->
GET /DMS/Installation%20Manual.htm HTTP/1.1
Host: 150.158.204.40
Connection: Keep-Alive
Response ->
HTTP/1.0 401 Unauthorized
Date: Tue, 11 Jul 2006 20:55:59 GMT
Connection: keep-alive
Server: Microsoft-WinCE/4.20
WWW-Authenticate: NTLM
WWW-Authenticate: Basic realm="Microsoft-WinCE"
Content-Type: text/html
Content-Length: 81
Request ->
GET /DMS/Installation%20Manual.htm HTTP/1.1
Authorization: Basic UEZFOnZpc2lvbg==
Host: 150.158.204.40
Connection: Keep-Alive
Response ->
<B>Access denied.</B><P>Client does not have access to the resource on the
serverHTTP/1.0 200 OK
Date: Tue, 11 Jul 2006 20:55:59 GMT
Connection: keep-alive
Server: Microsoft-WinCE/4.20
Last-Modified: Mon, 10 Jul 2006 12:23:36 GMT
ETag: "0149baa1ba4c61:820:7"
Content-Type: text/html
Content-Length: 37462
<html>
<head>
<meta http-equiv="Content-Language" content="nl-be">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>Installation Manual</title>
</head>
<body>
...
As you can see in the HTTP stream captured with Ethereal, the first
request fails with an error,
because no Authentication is used. The application then tries again with
an Authorization string in
the header. This request succeeds and the CE device start sending the HTML
content. However, the
.NET framework seems to ignore this content and throws the WebException
instead.
Note that I've already tried to add the "useUnsafeHeaderParsing" in the
config file, but without
success.
Does anyone have an idea what could be causing this problem?
Or how I can further debug this problem?
I've you need more tracing, please let me now.
Regards
Kris
.
- Follow-Ups:
- Re: The server committed a protocol violation
- From: Kris Mattheus
- Re: The server committed a protocol violation
- References:
- The server committed a protocol violation
- From: Kris Mattheus
- The server committed a protocol violation
- Prev by Date: Re: FTP server
- Next by Date: Serial port connection
- Previous by thread: The server committed a protocol violation
- Next by thread: Re: The server committed a protocol violation
- Index(es):
Relevant Pages
|
Loading