tiny
tiny

Reputation: 183

How to resolve the errror: "The underlying connection was closed"?

Does anyone know this problem:

"The underlying connection was closed: An unexpected error occurred on a receive."?

How can we resolve this problem?

Upvotes: 0

Views: 3415

Answers (4)

eKek0
eKek0

Reputation: 23289

A Google search for "The underlying connection was closed: An unexpected error occurred on a receive." throws these results.

From there this post:

...I have added the following code to my reference.cs file (which needs to be done each time I update the webservice reference) to assign the keepalive value to false to allow the connection to be closed and reopened.

protected override WebRequest GetWebRequest(Uri uri)
        {
            HttpWebRequest webRequest = (HttpWebRequest) base.GetWebRequest(uri);

            webRequest.KeepAlive = false;
            webRequest.ProtocolVersion=HttpVersion.Version10;
            return webRequest;
        }


I have also added a reference to System.Net via a using statement to

import the HttpWebRequest namespace.

Upvotes: 0

Goran
Goran

Reputation: 6846

This is a generic error that can be caused by just about anything (In my case some tiff images were causing gdi+ error in a wcf service).

Start by checking:

  1. IIS log files
  2. Application log files (ie. enable service logging if you use services)
  3. Permissions and security

Upvotes: 0

tiny
tiny

Reputation: 183

I have increased shutdown time in the application pool and now it's work fine.

Upvotes: 1

SpliFF
SpliFF

Reputation: 38956

yes, "the underlying connection was closed", or more precisely the browser was closed before the page loaded.

There's always the chance it's a real network level error (ie, bad proxy) but you don't provide enough detail.

Upvotes: 0

Related Questions