System.WebException | The operation has timed out

Discussion in 'ASP .Net' started by =?Utf-8?B?U2FjaGluIFN1cmFuYQ==?=, Feb 2, 2005.

  1. We use HttpWebRequest to send the request at a URL. But some times the method
    GetResponse throws a time out exception.

    But when we check the IIS logs, there is no such entry. So the request never
    reached the server but the client is getting a time out exception.

    What could be the possible reasons? Confirmed that the request does not get
    lost in the network.
    =?Utf-8?B?U2FjaGluIFN1cmFuYQ==?=, Feb 2, 2005
    #1
    1. Advertising

  2. Set the KeepAlive property of the HttpWebRequest object to false.

    When this is set to true, default, it will keep the connection open to your
    server. After a couple uses, the connection will timeout from the server,
    so the next time you make a request to it, it will try to use the "pooled"
    connection, but that pooled connection has timed out, thus you are receiving
    the error.

    private static string GetResponseString( string url )
    {
    HttpWebRequest request = ( HttpWebRequest ) WebRequest.Create( url );
    request.KeepAlive = false;
    using ( HttpWebResponse response = ( HttpWebResponse )
    request.GetResponse() )
    {
    using ( StreamReader reader = new StreamReader(
    response.GetResponseStream() ) )
    {
    return reader.ReadToEnd();
    }
    }
    }

    HTH,

    bill

    "Sachin Surana" <> wrote in message
    news:D...
    > We use HttpWebRequest to send the request at a URL. But some times the

    method
    > GetResponse throws a time out exception.
    >
    > But when we check the IIS logs, there is no such entry. So the request

    never
    > reached the server but the client is getting a time out exception.
    >
    > What could be the possible reasons? Confirmed that the request does not

    get
    > lost in the network.
    >
    >
    William F. Robertson, Jr., Feb 2, 2005
    #2
    1. Advertising

  3. Thanks.

    But I fail to understand one thing. Does that mean that .NET does not have a
    clena support for keep alives? Do you mean that if I ever use keep alives in
    ASPNET I will always get intermittent timeouts?

    Is there any patch available?

    Regards,
    SAchin



    "William F. Robertson, Jr." wrote:

    > Set the KeepAlive property of the HttpWebRequest object to false.
    >
    > When this is set to true, default, it will keep the connection open to your
    > server. After a couple uses, the connection will timeout from the server,
    > so the next time you make a request to it, it will try to use the "pooled"
    > connection, but that pooled connection has timed out, thus you are receiving
    > the error.
    >
    > private static string GetResponseString( string url )
    > {
    > HttpWebRequest request = ( HttpWebRequest ) WebRequest.Create( url );
    > request.KeepAlive = false;
    > using ( HttpWebResponse response = ( HttpWebResponse )
    > request.GetResponse() )
    > {
    > using ( StreamReader reader = new StreamReader(
    > response.GetResponseStream() ) )
    > {
    > return reader.ReadToEnd();
    > }
    > }
    > }
    >
    > HTH,
    >
    > bill
    >
    > "Sachin Surana" <> wrote in message
    > news:D...
    > > We use HttpWebRequest to send the request at a URL. But some times the

    > method
    > > GetResponse throws a time out exception.
    > >
    > > But when we check the IIS logs, there is no such entry. So the request

    > never
    > > reached the server but the client is getting a time out exception.
    > >
    > > What could be the possible reasons? Confirmed that the request does not

    > get
    > > lost in the network.
    > >
    > >

    >
    >
    >
    =?Utf-8?B?U2FjaGluIFN1cmFuYQ==?=, Feb 3, 2005
    #3
  4. No, I believe the support is there. KeepAlive = true will instruct the
    webserver to keep a persistent connection open. You are timing out because
    the webserver has timed out the KeepAlive session, but you, the client, has
    not.

    When I experienced this problem, it was because I was making a hit to a
    webserver, then intermittedly making hits every second to an interval of 1
    hour. The first couple connections always worked, then they would start
    timing out, especially near the end of the day when the frequency of hits
    decreased.

    When I was testing and hitting the server every 5 seconds or so, I never
    received the timeout error. It was only in a production environment.

    If you don't feel comfortable setting the KeepAlive to false, then perhaps
    make you HttpWebRequest every couple seconds, then you might not experience
    this problem.

    I don't believe there is a patch, this is the behavior I would expect.

    HTH,

    bill

    "Sachin Surana" <> wrote in message
    news:...
    > Thanks.
    >
    > But I fail to understand one thing. Does that mean that .NET does not have

    a
    > clena support for keep alives? Do you mean that if I ever use keep alives

    in
    > ASPNET I will always get intermittent timeouts?
    >
    > Is there any patch available?
    >
    > Regards,
    > SAchin
    >
    >
    >
    > "William F. Robertson, Jr." wrote:
    >
    > > Set the KeepAlive property of the HttpWebRequest object to false.
    > >
    > > When this is set to true, default, it will keep the connection open to

    your
    > > server. After a couple uses, the connection will timeout from the

    server,
    > > so the next time you make a request to it, it will try to use the

    "pooled"
    > > connection, but that pooled connection has timed out, thus you are

    receiving
    > > the error.
    > >
    > > private static string GetResponseString( string url )
    > > {
    > > HttpWebRequest request = ( HttpWebRequest ) WebRequest.Create( url );
    > > request.KeepAlive = false;
    > > using ( HttpWebResponse response = ( HttpWebResponse )
    > > request.GetResponse() )
    > > {
    > > using ( StreamReader reader = new StreamReader(
    > > response.GetResponseStream() ) )
    > > {
    > > return reader.ReadToEnd();
    > > }
    > > }
    > > }
    > >
    > > HTH,
    > >
    > > bill
    > >
    > > "Sachin Surana" <> wrote in

    message
    > > news:D...
    > > > We use HttpWebRequest to send the request at a URL. But some times the

    > > method
    > > > GetResponse throws a time out exception.
    > > >
    > > > But when we check the IIS logs, there is no such entry. So the request

    > > never
    > > > reached the server but the client is getting a time out exception.
    > > >
    > > > What could be the possible reasons? Confirmed that the request does

    not
    > > get
    > > > lost in the network.
    > > >
    > > >

    > >
    > >
    > >
    William F. Robertson, Jr., Feb 3, 2005
    #4
  5. Yes, it is webserver that has timed out. But the error I am receiving is at
    the client side.

    When web server times out, the error received by the client is "The
    underlying connection is closed. Unexpected error occured on receive"

    But when client times out, the error received is "The operation has timed
    out".

    SO it is client that is timing out and intermittently. Please let me know if
    I am correct.

    And, I receive the error exactly after 60 seconds.


    "William F. Robertson, Jr." wrote:

    > No, I believe the support is there. KeepAlive = true will instruct the
    > webserver to keep a persistent connection open. You are timing out because
    > the webserver has timed out the KeepAlive session, but you, the client, has
    > not.
    >
    > When I experienced this problem, it was because I was making a hit to a
    > webserver, then intermittedly making hits every second to an interval of 1
    > hour. The first couple connections always worked, then they would start
    > timing out, especially near the end of the day when the frequency of hits
    > decreased.
    >
    > When I was testing and hitting the server every 5 seconds or so, I never
    > received the timeout error. It was only in a production environment.
    >
    > If you don't feel comfortable setting the KeepAlive to false, then perhaps
    > make you HttpWebRequest every couple seconds, then you might not experience
    > this problem.
    >
    > I don't believe there is a patch, this is the behavior I would expect.
    >
    > HTH,
    >
    > bill
    >
    > "Sachin Surana" <> wrote in message
    > news:...
    > > Thanks.
    > >
    > > But I fail to understand one thing. Does that mean that .NET does not have

    > a
    > > clena support for keep alives? Do you mean that if I ever use keep alives

    > in
    > > ASPNET I will always get intermittent timeouts?
    > >
    > > Is there any patch available?
    > >
    > > Regards,
    > > SAchin
    > >
    > >
    > >
    > > "William F. Robertson, Jr." wrote:
    > >
    > > > Set the KeepAlive property of the HttpWebRequest object to false.
    > > >
    > > > When this is set to true, default, it will keep the connection open to

    > your
    > > > server. After a couple uses, the connection will timeout from the

    > server,
    > > > so the next time you make a request to it, it will try to use the

    > "pooled"
    > > > connection, but that pooled connection has timed out, thus you are

    > receiving
    > > > the error.
    > > >
    > > > private static string GetResponseString( string url )
    > > > {
    > > > HttpWebRequest request = ( HttpWebRequest ) WebRequest.Create( url );
    > > > request.KeepAlive = false;
    > > > using ( HttpWebResponse response = ( HttpWebResponse )
    > > > request.GetResponse() )
    > > > {
    > > > using ( StreamReader reader = new StreamReader(
    > > > response.GetResponseStream() ) )
    > > > {
    > > > return reader.ReadToEnd();
    > > > }
    > > > }
    > > > }
    > > >
    > > > HTH,
    > > >
    > > > bill
    > > >
    > > > "Sachin Surana" <> wrote in

    > message
    > > > news:D...
    > > > > We use HttpWebRequest to send the request at a URL. But some times the
    > > > method
    > > > > GetResponse throws a time out exception.
    > > > >
    > > > > But when we check the IIS logs, there is no such entry. So the request
    > > > never
    > > > > reached the server but the client is getting a time out exception.
    > > > >
    > > > > What could be the possible reasons? Confirmed that the request does

    > not
    > > > get
    > > > > lost in the network.
    > > > >
    > > > >
    > > >
    > > >
    > > >

    >
    >
    >
    =?Utf-8?B?U2FjaGluIFN1cmFuYQ==?=, Feb 6, 2005
    #5
  6. I was thinking something else entirely different.

    Setting KeepAlive to false did not help resolve any of the timeouts?

    When your client is making a HttpWebRequest to the server. You receive one
    of two timeouts?

    Either the Server bombs with "Underlying connection closed."
    Or the Client bombs with "The operation has timed out"

    The only thing left I could possibly help you with is for you to post your
    code and I will look at it and see if there is anything squirrelly

    bill

    "Sachin Surana" <> wrote in message
    news:...
    > Yes, it is webserver that has timed out. But the error I am receiving is

    at
    > the client side.
    >
    > When web server times out, the error received by the client is "The
    > underlying connection is closed. Unexpected error occured on receive"
    >
    > But when client times out, the error received is "The operation has timed
    > out".
    >
    > SO it is client that is timing out and intermittently. Please let me know

    if
    > I am correct.
    >
    > And, I receive the error exactly after 60 seconds.
    >
    >
    > "William F. Robertson, Jr." wrote:
    >
    > > No, I believe the support is there. KeepAlive = true will instruct the
    > > webserver to keep a persistent connection open. You are timing out

    because
    > > the webserver has timed out the KeepAlive session, but you, the client,

    has
    > > not.
    > >
    > > When I experienced this problem, it was because I was making a hit to a
    > > webserver, then intermittedly making hits every second to an interval of

    1
    > > hour. The first couple connections always worked, then they would start
    > > timing out, especially near the end of the day when the frequency of

    hits
    > > decreased.
    > >
    > > When I was testing and hitting the server every 5 seconds or so, I never
    > > received the timeout error. It was only in a production environment.
    > >
    > > If you don't feel comfortable setting the KeepAlive to false, then

    perhaps
    > > make you HttpWebRequest every couple seconds, then you might not

    experience
    > > this problem.
    > >
    > > I don't believe there is a patch, this is the behavior I would expect.
    > >
    > > HTH,
    > >
    > > bill
    > >
    > > "Sachin Surana" <> wrote in

    message
    > > news:...
    > > > Thanks.
    > > >
    > > > But I fail to understand one thing. Does that mean that .NET does not

    have
    > > a
    > > > clena support for keep alives? Do you mean that if I ever use keep

    alives
    > > in
    > > > ASPNET I will always get intermittent timeouts?
    > > >
    > > > Is there any patch available?
    > > >
    > > > Regards,
    > > > SAchin
    > > >
    > > >
    > > >
    > > > "William F. Robertson, Jr." wrote:
    > > >
    > > > > Set the KeepAlive property of the HttpWebRequest object to false.
    > > > >
    > > > > When this is set to true, default, it will keep the connection open

    to
    > > your
    > > > > server. After a couple uses, the connection will timeout from the

    > > server,
    > > > > so the next time you make a request to it, it will try to use the

    > > "pooled"
    > > > > connection, but that pooled connection has timed out, thus you are

    > > receiving
    > > > > the error.
    > > > >
    > > > > private static string GetResponseString( string url )
    > > > > {
    > > > > HttpWebRequest request = ( HttpWebRequest ) WebRequest.Create(

    url );
    > > > > request.KeepAlive = false;
    > > > > using ( HttpWebResponse response = ( HttpWebResponse )
    > > > > request.GetResponse() )
    > > > > {
    > > > > using ( StreamReader reader = new StreamReader(
    > > > > response.GetResponseStream() ) )
    > > > > {
    > > > > return reader.ReadToEnd();
    > > > > }
    > > > > }
    > > > > }
    > > > >
    > > > > HTH,
    > > > >
    > > > > bill
    > > > >
    > > > > "Sachin Surana" <> wrote in

    > > message
    > > > > news:D...
    > > > > > We use HttpWebRequest to send the request at a URL. But some times

    the
    > > > > method
    > > > > > GetResponse throws a time out exception.
    > > > > >
    > > > > > But when we check the IIS logs, there is no such entry. So the

    request
    > > > > never
    > > > > > reached the server but the client is getting a time out exception.
    > > > > >
    > > > > > What could be the possible reasons? Confirmed that the request

    does
    > > not
    > > > > get
    > > > > > lost in the network.
    > > > > >
    > > > > >
    > > > >
    > > > >
    > > > >

    > >
    > >
    > >
    William F. Robertson, Jr., Feb 8, 2005
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Steve
    Replies:
    0
    Views:
    5,311
    Steve
    Jul 1, 2003
  2. Matt
    Replies:
    0
    Views:
    3,969
  3. nirav.zenith
    Replies:
    1
    Views:
    9,990
    AhmedFarouk
    Feb 1, 2009
  4. Matt H.
    Replies:
    1
    Views:
    3,593
    George
    May 11, 2009
  5. Replies:
    0
    Views:
    454
Loading...

Share This Page