[Mono-dev] After two tried I get a System.Net.WebException: The request timed out

Sunny sloncho at gmail.com
Tue May 2 17:43:18 EDT 2006


On 5/2/06, Carlos Solorzano <carlos at applianz.com> wrote:
> Can someone else confirm this with me, I have an infinite loop calling a
> webpage (google is there just for you guys but I was calling a server
> internal to my network). On windows it runs fine but on mono I get a
> timeout after the second try. I have 1.1.10.1
>
> using System;
>
> namespace ConsoleApplication4
> {
>     /// <summary>
>     /// Summary description for Class1.
>     /// </summary>
>     class Class1
>     {
>         /// <summary>
>         /// The main entry point for the application.
>         /// </summary>
>         [STAThread]
>         static void Main(string[] args)
>         {
>             int i = 0;
>             while(true)
>             {
>
>                 try
>                 {
>
> System.Net.WebRequest.Create("http://google.com").GetResponse().GetResponseStream().ReadByte();
>                     Console.WriteLine("new conn " + (i++)  );
>                 }
>                 catch(Exception ex)
>                 {
>                     Console.WriteLine("ERROR: " + ex);
>                 }
>                 System.Threading.Thread.Sleep(1000);
>             }
>         }
>     }
> }
>
> #mono ConsoleApplication4.exe
> new conn 0
> new conn 1
> ERROR: System.Net.WebException: The request timed out
> in <0x00147> System.Net.HttpWebRequest:EndGetResponse (IAsyncResult
> asyncResult)
> in <0x00047> System.Net.HttpWebRequest:GetResponse ()
> in <0x00033> ConsoleApplication4.Class1:Main (System.String[] args)
>

You can/will have problems with this approach under Windows as well.
You do not close the stream, thus not closing the connection. By
default you have only 2 web connections per host, and the next
connections are queued. There may be a bug/problem with the mono
implementation, which does not autoclose the connections in the
timeout period though.

--
--
Svetoslav Milenov (Sunny)

Windows is a 32-bit extension to a 16-bit graphical shell for an 8-bit
operating system originally coded for a 4-bit microprocessor by a
2-bit company that can't stand 1 bit of competition.


More information about the Mono-devel-list mailing list