HttpWebRequest.KeepAlive setting and web exception ‘RequestCancele

Discussion in 'ASP .Net Web Services' started by TBATravel, Aug 17, 2007.

  1. TBATravel

    TBATravel Guest

    Hi,

    Ours is an ASP.NET 2.0 web application interacting with a third-party web
    service hosted on Tomcat servers.

    When client application submits the web request to the web service from the
    Production servers, we observe the frequent occurrence of the error 'The
    request was aborted: The request was canceled. at
    System.Net.HttpWebRequest.GetResponse()'.
    The status of the web exception received is ‘RequestCanceled’, which is the
    default status.

    In these cases, it is observed that no request from the ASP.NET client is
    hitting the Tomcat servers and the time at which the error is getting logged
    is almost instantaneous after submitting the request. So, it looks like the
    connection to the server is not available when the client application expects
    it to be open.

    This issue is affecting our existing customers to a greater extent.
    Can you please let us know the cause for this issue and the solution for the
    same?

    Note : From the information available, we understand that one possible
    solution for this issue is - setting ‘HttpWebRequest.KeepAlive = false’. But
    we also understand that this would slow down the process by opening a new
    connection for each request. Hence we are hesitant to follow this approach,
    as our application is live and several customers are currently using it.
    Obviously we do not want to slow down the response times.
    Can you please let us know whether setting this ‘KeepAlive’ to ‘false’ be
    advisable and the impact of the same?
    ---
    Thanks,
    Priya
    TBATravel, Aug 17, 2007
    #1
    1. Advertising

  2. "TBATravel" <> wrote in message
    news:...
    > Hi,
    >
    > Ours is an ASP.NET 2.0 web application interacting with a third-party web
    > service hosted on Tomcat servers.
    >
    > When client application submits the web request to the web service from
    > the
    > Production servers, we observe the frequent occurrence of the error 'The
    > request was aborted: The request was canceled. at
    > System.Net.HttpWebRequest.GetResponse()'.
    > The status of the web exception received is ‘RequestCanceled’, which is
    > the
    > default status.
    >
    > In these cases, it is observed that no request from the ASP.NET client is
    > hitting the Tomcat servers and the time at which the error is getting
    > logged
    > is almost instantaneous after submitting the request. So, it looks like
    > the
    > connection to the server is not available when the client application
    > expects
    > it to be open.


    No, it looks like the Tomcat side sees no packets from your client, and like
    your client is failing to communicate with the Tomcat side. Don't assume
    that the connection is unavailable. In fact, don't assume anything yet.

    I suggest you take a look at the network traffic between the client and the
    server when the problem occurs. You can start with doing a "tracert" command
    from a Command Prompt window ON THE CLIENT MACHINE as soon as the problem
    occurs. Use "tracert -d <<servername>>" (the "-d" displays the output as
    numeric, without depending on a DNS server to translate it into a host
    name). tracert may give you some idea about your general connectivity at
    that time.

    Similarly, try "ping <<servername>>". See if you can get there. If you can,
    great, but if you can't, it's not proof - there could be a firewall or
    something else preventing the ping request from reaching the server or
    preventing the server from responding.

    Another trick is to use the old "telnet" command from the Command Prompt
    window. Use:

    -----------------------------------
    C:> telnet <<servername>> 80
    GET /
    -----------------------------------

    You may not have known this, but HTTP is based on the same protocol as the
    old remote terminal protocol, "telnet". If you telnet to the port your
    server is meant to be listening on, you can manually send a simple HTTP
    request. If you can't connect with telnet, then your client won't be able to
    connect, either. If you _can_ connect, but get an error message when you do
    a "GET /" or "GET /servicepath/servicename.asmx", then your client would
    likely get the same error.

    You may try looking at the traffic from the client. I suggest you do so from
    a point on the same network segment as the client, and in fact a location
    physically close to the client. Look to see what, if any, traffic comes from
    the client when the problem occurs. In particular, if there are any
    responses at all to the messages from the client, then it tells you that you
    have connectivity to whatever responded.
    --
    John Saunders [MVP]
    John Saunders [MVP], Aug 17, 2007
    #2
    1. Advertising

  3. TBATravel

    Jp Guest

    Re: HttpWebRequest.KeepAlive setting and web exception ‘RequestCan

    Hi John,

    Thanks for the response.

    As this issue of ‘Request aborted. Request Canceled’ occurs only in the
    Production environment, there are some practical difficulties (due to the
    restricted access) in carrying out the exercise you have suggested.
    There are multiple servers on which the application is hosted and so it is
    not possible to monitor the logs in all the servers continuously and track
    them.

    Moreover, from the analysis done with the available logs, we can observe
    that there are some successful responses almost immediately after the error
    ‘Request aborted’ have been logged on the same server.

    Let us consider the case below:
    - In one of the servers, at TimeStamp 05:30:19 - First request got logged.
    - Immediately at the same time 05:30:19 - 'The request was aborted: The
    request was canceled. at System.Net.HttpWebRequest.GetResponse()' error got
    logged.
    - The second request got logged at 05:30:20.
    - Proper response for the second request got logged at 05:30:24.
    In this case, as it is evident the request at 05:30:19 got aborted and the
    request at 05:30:20 worked fine. So, as you would agree it is practically not
    possible to try the ‘tracert’, ‘ping’ or ‘telnet’ within one second.

    Please let us know the further possible suggestions / fix for this issue.

    We feel that identifying the exact root cause of this issue and fixing it
    may not be immediate.
    In the meanwhile, we would like to follow the approach
    ‘HttpWebRequest.KeepAlive = false’ as our live customers are severely
    impacted by this issue.
    Can you please let us know whether setting this ‘KeepAlive’ to ‘false’ be
    advisable and the impact of the same?

    Thanks,
    Jp

    "John Saunders [MVP]" wrote:

    >
    > "TBATravel" <> wrote in message
    > news:...
    > > Hi,
    > >
    > > Ours is an ASP.NET 2.0 web application interacting with a third-party web
    > > service hosted on Tomcat servers.
    > >
    > > When client application submits the web request to the web service from
    > > the
    > > Production servers, we observe the frequent occurrence of the error 'The
    > > request was aborted: The request was canceled. at
    > > System.Net.HttpWebRequest.GetResponse()'.
    > > The status of the web exception received is ‘RequestCanceled’, which is
    > > the
    > > default status.
    > >
    > > In these cases, it is observed that no request from the ASP.NET client is
    > > hitting the Tomcat servers and the time at which the error is getting
    > > logged
    > > is almost instantaneous after submitting the request. So, it looks like
    > > the
    > > connection to the server is not available when the client application
    > > expects
    > > it to be open.

    >
    > No, it looks like the Tomcat side sees no packets from your client, and like
    > your client is failing to communicate with the Tomcat side. Don't assume
    > that the connection is unavailable. In fact, don't assume anything yet.
    >
    > I suggest you take a look at the network traffic between the client and the
    > server when the problem occurs. You can start with doing a "tracert" command
    > from a Command Prompt window ON THE CLIENT MACHINE as soon as the problem
    > occurs. Use "tracert -d <<servername>>" (the "-d" displays the output as
    > numeric, without depending on a DNS server to translate it into a host
    > name). tracert may give you some idea about your general connectivity at
    > that time.
    >
    > Similarly, try "ping <<servername>>". See if you can get there. If you can,
    > great, but if you can't, it's not proof - there could be a firewall or
    > something else preventing the ping request from reaching the server or
    > preventing the server from responding.
    >
    > Another trick is to use the old "telnet" command from the Command Prompt
    > window. Use:
    >
    > -----------------------------------
    > C:> telnet <<servername>> 80
    > GET /
    > -----------------------------------
    >
    > You may not have known this, but HTTP is based on the same protocol as the
    > old remote terminal protocol, "telnet". If you telnet to the port your
    > server is meant to be listening on, you can manually send a simple HTTP
    > request. If you can't connect with telnet, then your client won't be able to
    > connect, either. If you _can_ connect, but get an error message when you do
    > a "GET /" or "GET /servicepath/servicename.asmx", then your client would
    > likely get the same error.
    >
    > You may try looking at the traffic from the client. I suggest you do so from
    > a point on the same network segment as the client, and in fact a location
    > physically close to the client. Look to see what, if any, traffic comes from
    > the client when the problem occurs. In particular, if there are any
    > responses at all to the messages from the client, then it tells you that you
    > have connectivity to whatever responded.
    > --
    > John Saunders [MVP]
    >
    >
    >
    Jp, Aug 21, 2007
    #3
  4. Re: HttpWebRequest.KeepAlive setting and web exception ‘RequestCan

    "Jp" <> wrote in message
    news:...
    > Hi John,
    >
    > Thanks for the response.
    >
    > As this issue of ‘Request aborted. Request Canceled’ occurs only in the
    > Production environment, there are some practical difficulties (due to the
    > restricted access) in carrying out the exercise you have suggested.
    > There are multiple servers on which the application is hosted and so it is
    > not possible to monitor the logs in all the servers continuously and track
    > them.
    >
    > Moreover, from the analysis done with the available logs, we can observe
    > that there are some successful responses almost immediately after the
    > error
    > ‘Request aborted’ have been logged on the same server.
    >
    > Let us consider the case below:
    > - In one of the servers, at TimeStamp 05:30:19 - First request got logged.
    > - Immediately at the same time 05:30:19 - 'The request was aborted: The
    > request was canceled. at System.Net.HttpWebRequest.GetResponse()' error
    > got
    > logged.
    > - The second request got logged at 05:30:20.
    > - Proper response for the second request got logged at 05:30:24.
    > In this case, as it is evident the request at 05:30:19 got aborted and the
    > request at 05:30:20 worked fine. So, as you would agree it is practically
    > not
    > possible to try the ‘tracert’, ‘ping’ or ‘telnet’ within one second.
    >
    > Please let us know the further possible suggestions / fix for this issue.
    >
    > We feel that identifying the exact root cause of this issue and fixing it
    > may not be immediate.
    > In the meanwhile, we would like to follow the approach
    > ‘HttpWebRequest.KeepAlive = false’ as our live customers are severely
    > impacted by this issue.
    > Can you please let us know whether setting this ‘KeepAlive’ to ‘false’ be
    > advisable and the impact of the same?


    I haven't used this feature myself, so I can't say. The effect of setting it
    to false should be that the connection between client and server will be
    closed after each request/response pair. There will be the added overhead of
    a new connection being established and torn down for each request.
    --
    John Saunders [MVP]
    John Saunders [MVP], Aug 21, 2007
    #4
  5. TBATravel

    Jp Guest

    Re: HttpWebRequest.KeepAlive setting and web exception ‘RequestCan

    Hi John,

    Thanks for your response.

    Regards,
    Jp


    > I haven't used this feature myself, so I can't say. The effect of setting it
    > to false should be that the connection between client and server will be
    > closed after each request/response pair. There will be the added overhead of
    > a new connection being established and torn down for each request.
    > --
    > John Saunders [MVP]
    >
    >
    Jp, Aug 24, 2007
    #5
  6. TBATravel

    TBATravel Guest

    Re: HttpWebRequest.KeepAlive setting and web exception ‘RequestCan

    Microsoft experts could provide some help/guidance?
    --
    Thanks,
    Priya


    "Jp" wrote:

    > Hi John,
    >
    > Thanks for your response.
    >
    > Regards,
    > Jp
    >
    >
    > > I haven't used this feature myself, so I can't say. The effect of setting it
    > > to false should be that the connection between client and server will be
    > > closed after each request/response pair. There will be the added overhead of
    > > a new connection being established and torn down for each request.
    > > --
    > > John Saunders [MVP]
    > >
    > >
    TBATravel, Aug 24, 2007
    #6
  7. TBATravel

    WSS Guest

    Re: HttpWebRequest.KeepAlive setting and web exception ‘RequestCan

    Priya,

    my project is also facing the similar problem in the weblogic server (where
    the web service being consumed from .net is hosted), however when using the
    tomcat server u can raise the keepalive interval higher than that of web
    server you are using. this will keep the connection open so that u can
    communicate with simultaneous requests.

    go to the post made by Mark in the thread

    https://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=228977&SiteID=1



    "TBATravel" wrote:

    > Microsoft experts could provide some help/guidance?
    > --
    > Thanks,
    > Priya
    >
    >
    > "Jp" wrote:
    >
    > > Hi John,
    > >
    > > Thanks for your response.
    > >
    > > Regards,
    > > Jp
    > >
    > >
    > > > I haven't used this feature myself, so I can't say. The effect of setting it
    > > > to false should be that the connection between client and server will be
    > > > closed after each request/response pair. There will be the added overhead of
    > > > a new connection being established and torn down for each request.
    > > > --
    > > > John Saunders [MVP]
    > > >
    > > >
    WSS, Oct 10, 2007
    #7
  8. TBATravel

    TBATravel Guest

    Re: HttpWebRequest.KeepAlive setting and web exception ‘RequestCan

    Thanks for your help...
    we are in the process of doing same and hope this will work as you said
    --
    Thanks,
    Priya


    "WSS" wrote:

    > Priya,
    >
    > my project is also facing the similar problem in the weblogic server (where
    > the web service being consumed from .net is hosted), however when using the
    > tomcat server u can raise the keepalive interval higher than that of web
    > server you are using. this will keep the connection open so that u can
    > communicate with simultaneous requests.
    >
    > go to the post made by Mark in the thread
    >
    > https://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=228977&SiteID=1
    >
    >
    >
    > "TBATravel" wrote:
    >
    > > Microsoft experts could provide some help/guidance?
    > > --
    > > Thanks,
    > > Priya
    > >
    > >
    > > "Jp" wrote:
    > >
    > > > Hi John,
    > > >
    > > > Thanks for your response.
    > > >
    > > > Regards,
    > > > Jp
    > > >
    > > >
    > > > > I haven't used this feature myself, so I can't say. The effect of setting it
    > > > > to false should be that the connection between client and server will be
    > > > > closed after each request/response pair. There will be the added overhead of
    > > > > a new connection being established and torn down for each request.
    > > > > --
    > > > > John Saunders [MVP]
    > > > >
    > > > >
    TBATravel, Oct 11, 2007
    #8
    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. Aps
    Replies:
    0
    Views:
    778
  2. loial

    ssh keepalive

    loial, Oct 1, 2008, in forum: Python
    Replies:
    5
    Views:
    389
    Gabriel Genellina
    Oct 2, 2008
  3. TDC
    Replies:
    6
    Views:
    2,366
  4. Mark Shaw

    (KeepAlive = false) == 401 ACCESS DENIED!!

    Mark Shaw, Dec 5, 2003, in forum: ASP .Net Web Services
    Replies:
    3
    Views:
    122
    Feroze [MSFT]
    Dec 17, 2003
  5. dave_benedict

    TCPClient and KeepAlive

    dave_benedict, Mar 2, 2005, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    171
    dave_benedict
    Mar 2, 2005
Loading...

Share This Page