Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / July 2005

Tip: Looking for answers? Try searching our database.

WebExceptionStatus.ReceiveFailure

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Sergey - 23 Jun 2005 15:14 GMT
   Hi, everybody.

   Do you know, which HTTP response produces WebException with Status ==
WebExceptionStatus.ReceiveFailure?
   I get this exception raised in my small C# tool whenever the HTTP server
returns HTTP/1.1 200 OK with no more data in the response body. If there are
some other data after 200 OK, then no WebException is thrown.
   Can it be that the reason of WebException in this case is the absence of
the response body? Because in RFC2616 it is mentioned that in case when
response contains no data the correct HTTP answer code must be "204 No
Content".

   If this is wrong newsgroup could you please give me a hint, where can I
receive an answer on my question?

   Thank you.
   Sergey.
Joerg Jooss - 26 Jun 2005 06:36 GMT
>     Hi, everybody.
>
[quoted text clipped - 7 lines]
> mentioned that in case when response contains no data the correct
> HTTP answer code must be "204 No Content".

Can you capture the HTTP traffic using Fiddler (www.fiddlertool.com)?

Cheers,
Signature

http://www.joergjooss.de
mailto:news-reply@joergjooss.de

Sergey - 28 Jun 2005 08:34 GMT
   No, I can not. I am sending HTTP POST reqests from my tool and the body
of these requests has binary form. I could not find the way how to simulate
that with fiddler tool. But I can easyly make dumps with Ethereal.
   The problem now looks for me a little bit different. Exception is raised
not on 200 OK with empty body but rather on something like broken connection
when it takes time for my remote hardware embedded HTTP server to process
incoming request. It happend simply more often when the response was 200 OK
and no message body attached.
   Could the reason of WebException WebExceptionStatus.ReceiveFailure
status be the broken or mishandled connection?
   Am I applying correct procedure for send request/read response?

int ret = 0;

HttpWebResponse hwResponse = null;

Stream sr = null;

HttpWebRequest hwreq = _prepareRequest(cgi,cmdLen);

Stream s = hwr.GetRequestStream();

s.Write(buf,0,len);

s.Close();

try

{

   hwResponse = (HttpWebResponse) hwr.GetResponse();

   if(hwResponse.StatusCode == HttpStatusCode.OK)

   {

       if(hwr.HaveResponse)

       {

           sr = hwResponse.GetResponseStream();

           int offset=0;

           int remaining = len;

           while (remaining > 0)

           {

               int read = sr.Read(buf, offset, remaining);

               if (read <= 0)

                   break;

               remaining -= read;

           offset += read;

       }

       ret = len - remaining;

   }

}

catch(WebException we)

{

   if(we.Status == WebExceptionStatus.ProtocolError)

   {

       throw we;

   }

}

finally

{

   if(sr != null)

       sr.Close();

   if(hwResponse != null)

       hwResponse.Close();

}

> >     Hi, everybody.
> >
[quoted text clipped - 11 lines]
>
> Cheers,
Joerg Jooss - 01 Jul 2005 08:04 GMT
>     No, I can not. I am sending HTTP POST reqests from my tool and
> the body of these requests has binary form. I could not find the way
> how to simulate that with fiddler tool.

Hm... why "simulate"? Just run it as proxy and look what happens...

> But I can easyly make dumps with Ethereal.      

Fair enough!

> The problem now looks for me a little bit
> different. Exception is raised not on 200 OK with empty body but
[quoted text clipped - 5 lines]
> connection?      Am I applying correct procedure for send
> request/read response?

Assuming _pepareRequest doesn't do silly thing, your code looks OK. I'm
not sure that the client side is the culprit here. Could it be that the
server really stops sending while streaming back a response?

Cheers,
Signature

http://www.joergjooss.de
mailto:news-reply@joergjooss.de


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.