The underlying connection was closed: Unable to connect to the remote server.

we were in the technical problem since since last couple of the days. we googled it a lot , however after all we have done it today :). special thanks to Jigar Pandit for the same.

Problem:
Web service call is working fine in our local system. however when we installed middle-tier service (which contains dll of web-service call) on remote server. it started giving “The underlying connection was closed: Unable to connect to the remote server.” Error. 

Description
This problem may occur when one or more of the following conditions are true:

A network outage occurs.
A proxy server blocks the HTTP request.
A Domain Name System (DNS) problem occurs.
A network authentication problem occurs.

Resolution

To resolve this problem, make sure that the proxy settings are correct. To do this, use the following techniques:

Use the static WebProxy.GetDefaultProxy method. For more information, visit the following Microsoft Web site:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemnetwebproxyclassgetdefaultproxytopic.asp (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemnetwebproxyclassgetdefaultproxytopic.asp)

Define a <proxy> element in the application configuration files. For more information, visit the following Microsoft Web site:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/gngrfproxyelement.asp (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/gngrfproxyelement.asp)

Configure the .NET client to use HTTP 1.0 by changing the HttpWebRequest.ProtocolVersion property. For more information, visit the following Microsoft Web site:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemnethttpwebrequestclassprotocolversiontopic.asp (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemnethttpwebrequestclassprotocolversiontopic.asp)

Note By default, the .NET Framework uses HTTP 1.1.

Out of this 3 option, first one works for us.

Reference Taken From
http://support.microsoft.com/kb/915599/en-us

Advertisements

4 Responses to The underlying connection was closed: Unable to connect to the remote server.

  1. Shwetha says:

    I have a problem with the error “The underlying connection was closed. The server committed an HTTP protocol violation”. I have googled a lot tried all the possible solutions for this error i.e. changing the machine/web . config files. setting keep alive property etc. Nothing worked for me. but, when i have set the HTTP protocol version to 1.0, it worked for me. I just want to know the reason, why this works? why will it work setting the HTTP protocol version to 1.0. One of the customer is facing this problem. We are not able to reproduce the problem.

  2. Idetrorce says:

    very interesting, but I don’t agree with you
    Idetrorce

  3. Rod Fornillos IV says:

    thanks for the information. m still having a problem though… i’ve created a web service in asp.net 2.0. and deployed it in one of our remote server.

    i’ve developed a simple application that will consume the service, in my local machine, and it works. however, when i tried to use the web service in another application (let’s call this “web application b”), i get that error.

    basically, “web application b” is deployed in that same remote server as the web service, only a different virtual folder.

    i’m not sure if this will help, but the remote server hosts 3 websites (sharing the same IP), with each one having their own host header. so we can say that both “web application b” and “web service” are running on say “Website A”, only with their own respective virtual directory.

    hope you can help.

  4. vivek says:

    HI Shwetha,

    I am facing the same problem. could you please tell me that where do i set the Http version 1.0 . If it is in web.config file,where do i write this,i mean under which tag.Can you please provide me the XML tag.

    Waiting for your response.

    Regards,
    Vivek

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: