By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,236 Members | 1,848 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,236 IT Pros & Developers. It's quick & easy.

Unexpected behavior - getting exception - Underlying connection cl

P: n/a
As per our requirements we have a web service which internally connects
(Simple HTTP Post Request) to a remote server to initiate some work. We are
calling the web service method asynchronously from a .NET Web Application
hosted on IIS. In our setup the web request form a client can be running for
long duration (may be more than 4 hours).

We are getting exceptions during the HTTP send/receive inside the web
service method. The exception are coming only during high load (for instance
when the pending web request count exceeds 45). For each web request the web
service internally do 10 iterations of Http send/receive (each iteration uses
a new Http connection). There is no fixed pattern in the type of exception
raised.

Following exceptions are coming:

1. The underlying connection was closed: An unexpected error occurred on a
receive
Status of Web Exception: ReceiveFailure
2. The underlying connection was closed: An unexpected error occurred on a
send
Status of Web Exception: SendFailure
3. The underlying connection was closed: Unable to connect to the remote
server
Status of Web Exception: ConnectFailure
4. The underlying connection was closed: The request was canceled
Status of Web Exception: RequestCanceled

I am using .NET Framework 1.1
Web Service and web application both are written in .NET and hosted on
Win2003. I had tested replacing web application with windows application but
got no improvement.
I have also observed that number RequestCancled exception has decreased once
we moved our web service form Win2000 Server to Win2003 Server.

I have tried the .NET bug fix by setting *keepalive* to false but still
getting exceptions.

I had modified the .NET config timeout settings to higher values.

<CODE>

HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create("URL");
webRequest.KeepAlive = false;
webRequest.ProtocolVersion=HttpVersion.Version10;
webRequest.Timeout = timeOut;
webRequest.Proxy = GlobalProxySelection.GetEmptyWebProxy();
webRequest.Method = "POST";
webRequest.ContentType="application/x-www-form-urlencoded";
StreamWriter myWriter = new StreamWriter(webRequest.GetRequestStream());
myWriter.Write("some post Data");
myWriter.Close();
WebResponse httpWebRes = httpWebRequest.GetResponse();
// Do some work with httpWebRes
httpWebRes.Close();

</CODE>

Thanks in advance.

--
Cheers,
Rahul Anand
Mar 28 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
q
"some post Data" isn't a valid SOAP message. Web services communicate
with SOAP messages. You send it proper XML and you will (possibly) get
proper XML back.

Here are samples of what you have to send and what may be returned:
http://terraserver-usa.com/TerraServ...p=GetPlaceList

Mar 28 '06 #2

P: n/a
"q" wrote:
"some post Data" isn't a valid SOAP message. Web services communicate
with SOAP messages. You send it proper XML and you will (possibly) get
proper XML back.

Here are samples of what you have to send and what may be returned:
http://terraserver-usa.com/TerraServ...p=GetPlaceList


The Web Service is working fine and we are getting correct output. The
exceptions are coming during the communication with some other remote server
in our web method.
I think the problem is not directly related to web service. I suspect some
problem in network comminucation may be during heavy load the network
resources are not available or something.

--
Cheers,
Rahul Anand
Mar 28 '06 #3

P: n/a
I think you mean to say "service" then... this is not a web service if
it's not dependent on XML messages (by definition, a web service uses
SOAP XML messages and interop with other web service platforms). I
think you want to be asking about how to deal with exceptions from
HttpWebRequest (which has nothing to do with web services).

Mar 28 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.