Closed connection is being re-used

Discussion in 'ASP .Net Web Services' started by Eric, May 18, 2005.

  1. Eric

    Eric Guest

    Hello,

    I have a windows service (written on .NET 1.1/C#) connecting to a webservice
    at a specified interval. I have a webreference in my project, create and
    instance of this object, and call my webservice methods. The interval was
    initially set to 60 seconds and everything was working fine. I changed the
    config so that the service is connecting to the webservice every 5 minutes.
    This is when i started getting the following error messages: 'The underlying
    connection was closed: An unexpected error occurred on a send.'

    I did some investigation on this error and used a packet sniffer to see what
    is exactly happening. The first time everything is working fine and after
    about 2 minutes the connection is reset. (Server sends TCP header with RST
    flag). The instance of proxy class (from webreference) does not detect the
    connection is reset and tries to connect over the closed connection. This
    causes the exception. The next call will succeed (a new connection is
    created), the following call will fail again etc. I thought that creating a
    new instance of the proxy class at every call and explicitly call Dispose()
    would fix my problem but it doesn't. There seems to be some connection
    pooling not removing closed connections?

    Any idea what causes this behaviour? Thanks in advance!

    Eric
     
    Eric, May 18, 2005
    #1
    1. Advertising

  2. I think your problem is in the IIS configureation there is a default
    timeout setting and i beleive it is set to 120 seconds. I am assuming
    your web service call is taking longer then 2 minutes to process. Try
    adjusting this settting it can be found in the properties window.
     
    Keenan Newton, May 18, 2005
    #2
    1. Advertising

  3. Eric

    Eric Guest

    No that is not the problem. It's not a single webservice call that takes
    more than 120 seconds. I do a call which is successful, wait 5 minutes, and
    perform another call. This second call is done over the same connection as
    the first call but this connection is no longer valid. I need to set up a
    new connection but somehow the generated proxy class chooses the closed
    connection causing the error.


    "Keenan Newton" <> wrote in message
    news:...
    >I think your problem is in the IIS configureation there is a default
    > timeout setting and i beleive it is set to 120 seconds. I am assuming
    > your web service call is taking longer then 2 minutes to process. Try
    > adjusting this settting it can be found in the properties window.
    >
     
    Eric, May 19, 2005
    #3
  4. Eric

    Eric Guest

    I found a solution to my problem! Add this code to your generated proxy
    class:

    protected override System.Net.WebRequest GetWebRequest(Uri uri)
    {
    System.Net.HttpWebRequest webRequest = (System.Net.HttpWebRequest)
    base.GetWebRequest(uri);
    webRequest.KeepAlive = false;
    return webRequest;
    }

    "Keenan Newton" <> wrote in message
    news:...
    >I think your problem is in the IIS configureation there is a default
    > timeout setting and i beleive it is set to 120 seconds. I am assuming
    > your web service call is taking longer then 2 minutes to process. Try
    > adjusting this settting it can be found in the properties window.
    >
     
    Eric, May 19, 2005
    #4
    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. news.microsoft.com
    Replies:
    2
    Views:
    508
    news.microsoft.com
    Dec 17, 2005
  2. Replies:
    2
    Views:
    958
  3. Glen
    Replies:
    3
    Views:
    2,566
  4. Apu Nahasapeemapetilon

    Established connection aborted and underlying connection closed

    Apu Nahasapeemapetilon, Nov 6, 2006, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    243
    Apu Nahasapeemapetilon
    Nov 6, 2006
  5. Matt Kruse
    Replies:
    5
    Views:
    334
    Richard Cornford
    Sep 9, 2003
Loading...

Share This Page