locked
The server committed a protocol violation. Section=ResponseStatusLine

    Question

  • Has anyone any idea what is happening here. I am trying to get a file from a webserver which is outside my corporate network, hence I have no control over that server and also I have to use a proxy.

     

    I was having problems in my service so I wrote a little windows app to test the network call. This is a snippit of that code. I've cut it down to the bare minimum.

     

    Dim imgURL As String = http://somewebsite.com/01/8a/018aceb8-bcc0-45c7-bff4-00025679bf0a.jpg

     

    Dim c As System.Net.WebClient = New System.Net.WebClient

    Dim cr As New System.Net.NetworkCredential("user", "pass", "domain")

    Dim pr As New System.Net.WebProxy("192.168.1.32", 80)

    pr.Credentials = cr

    c.Proxy = pr

    Dim s As IO.Stream = c.OpenRead(imgURL)

     

    When I try to run this the OpenRead throws an exception

    'The server committed a protocol violation. Section=ResponseStatusLine'

     

    I tried the useUnsafeHeaderParsing="true" fix but that had no effect, so in desperation I turned on tracing by placing the following in the app.config file

    <system.diagnostics>

    <sources>

    <source name="System.Net" tracemode="includehex" maxdatasize="1024">

    <listeners>

    <add name="System.Net"/>

    </listeners>

    </source>

    <source name="System.Net.Sockets">

    <listeners>

    <add name="System.Net"/>

    </listeners>

    </source>

    <source name="System.Net.Cache">

    <listeners>

    <add name="System.Net"/>

    </listeners>

    </source>

    </sources>

    <switches>

    <add name="System.Net.Sockets" value="Verbose"/>

    <add name="System.Net.Cache" value="Verbose"/>

    </switches>

    <sharedListeners>

    <add name="System.Net"

    type="System.Diagnostics.TextWriterTraceListener"

    initializeData="network.log"

    />

    </sharedListeners>

    <trace autoflush="true"/>

    </system.diagnostics>

     

    and run the app again. This time the exception did not occur. I then removed the tracing and the error came back.

     

    I messed around with the tracing and found that if I removed ether

    <add name="System.Net.Sockets" value="Verbose"/>

    or

    <add name="System.Net.Cache" value="Verbose"/>

    then the error occurs.

     

    Has anyone any idea what on earth is going on here.

     

    Thanks

    Terry

    Thursday, July 26, 2007 3:08 PM

All replies

  • What is the Response Status Line that you get from the server?

    Monday, July 30, 2007 6:35 AM
    Moderator
  • This is an extract of the trace I get. I have only shown this bit as the whole trace is massive. Also there is some stuff in the trace which I don't particularly wish to publish to the world. I hope this is the bit you require, if not please let me know specifically what you need.

     

    System.Net.Sockets Verbose: 0 : [4024] 00000000 : 48 54 54 50 2F 31 2E 30-20 32 30 30 20 4F 4B 0D : HTTP/1.0 200 OK.
    System.Net.Sockets Verbose: 0 : [4024] 00000010 : 0A 43 6F 6E 74 65 6E 74-2D 4C 65 6E 67 74 68 3A : .Content-Length:
    System.Net.Sockets Verbose: 0 : [4024] 00000020 : 20 31 34 31 39 31 0D 0A-43 6F 6E 74 65 6E 74 2D :  14191..Content-
    System.Net.Sockets Verbose: 0 : [4024] 00000030 : 54 79 70 65 3A 20 69 6D-61 67 65 2F 6A 70 65 67 : Type: image/jpeg
    System.Net.Sockets Verbose: 0 : [4024] 00000040 : 0D 0A 4C 61 73 74 2D 4D-6F 64 69 66 69 65 64 3A : ..Last-Modified:
    System.Net.Sockets Verbose: 0 : [4024] 00000050 : 20 57 65 64 2C 20 32 30-20 41 70 72 20 32 30 30 :  Wed, 20 Apr 200
    System.Net.Sockets Verbose: 0 : [4024] 00000060 : 35 20 31 32 3A 31 38 3A-32 33 20 47 4D 54 0D 0A : 5 12:18:23 GMT..
    System.Net.Sockets Verbose: 0 : [4024] 00000070 : 45 54 61 67 3A 20 22 38-30 36 30 35 61 63 61 33 : ETag: "80605aca3
    System.Net.Sockets Verbose: 0 : [4024] 00000080 : 34 35 63 35 31 3A 33 62-38 22 0D 0A 53 65 72 76 : 45c51:3b8"..Serv
    System.Net.Sockets Verbose: 0 : [4024] 00000090 : 65 72 3A 20 4D 69 63 72-6F 73 6F 66 74 2D 49 49 : er: Microsoft-II
    System.Net.Sockets Verbose: 0 : [4024] 000000A0 : 53 2F 36 2E 30 0D 0A 58-2D 50 6F 77 65 72 65 64 : S/6.0..X-Powered
    System.Net.Sockets Verbose: 0 : [4024] 000000B0 : 2D 42 79 3A 20 41 53 50-2E 4E 45 54 0D 0A 44 61 : -By: ASP.NET..Da
    System.Net.Sockets Verbose: 0 : [4024] 000000C0 : 74 65 3A 20 54 68 75 2C-20 32 36 20 4A 75 6C 20 : te: Thu, 26 Jul
    System.Net.Sockets Verbose: 0 : [4024] 000000D0 : 32 30 30 37 20 31 31 3A-32 31 3A 33 37 20 47 4D : 2007 11:21:37 GM
    System.Net.Sockets Verbose: 0 : [4024] 000000E0 : 54 0D 0A 56 69 61 3A 20-68 76 73 30 33 63 2E 66 : T..Via: hvs03c.f
    System.Net.Sockets Verbose: 0 : [4024] 000000F0 : 73 2E 66 75 6A 69 74 73-75 2E 63 6F 6D 0D 0A 58 : s.fujitsu.com..X
    System.Net.Sockets Verbose: 0 : [4024] 00000100 : 2D 43 61 63 68 65 3A 20-48 49 54 20 66 72 6F 6D : -Cache: HIT from
    System.Net.Sockets Verbose: 0 : [4024] 00000110 : 20 70 69 61 30 31 61 0D-0A 50 72 6F 78 79 2D 43 :  pia01a..Proxy-C
    System.Net.Sockets Verbose: 0 : [4024] 00000120 : 6F 6E 6E 65 63 74 69 6F-6E 3A 20 6B 65 65 70 2D : onnection: keep-
    System.Net.Sockets Verbose: 0 : [4024] 00000130 : 61 6C 69 76 65 0D 0A 0D-0A FF D8 FF E0 00 10 4A : alive..........J
    System.Net.Sockets Verbose: 0 : [4024] 00000140 : 46 49 46 00 01 01 00 00-01 00 01 00 00 FF DB 00 : FIF.............

     

    regards

    Terry

    Monday, July 30, 2007 9:41 AM
  • Thanks to anyone who read this and thought about the problem for me, however I have found a work around by using a different proxy which is based on a different product.

     

    The problem has gone away.

     

    Thanks

    Terry

    Thursday, August 02, 2007 3:21 PM
  • Good, I had suspected a bad proxy.  See the thread at http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1669900&SiteID=1 for a case where a broken proxy's mishandling of an 100 Continue intermediate response corrupted the web server's response.  Might be the same fault, butthe evidence was likely off the top of the block you showed.
    Saturday, August 04, 2007 9:23 AM