Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Security > The underlying connection was closed: An unexpected error occurred on a send

Reply
Thread Tools

The underlying connection was closed: An unexpected error occurred on a send

 
 
Tom
Guest
Posts: n/a
 
      05-11-2004
Dear all,
when I ran the following code, I always got "The underlying connection was closed: An unexpected error occurred on a send" error, it happend at "httpReq.GetResponse();" and the stack trace is
************start of stack trace***************************
The underlying connection was closed: An unexpected error occurred on a send. at System.Net.HttpWebRequest.CheckFinalS
tatus()
at System.Net.HttpWebRequest.EndGetResponse(IAsyncRes ult asyncResult)
at System.Net.HttpWebRequest.GetResponse()
***********end of stack trace**************88
Much appreciated for any help!
Tom
************************************************** **
try
{
HttpWebRequest httpReq = (HttpWebRequest) WebRequest.Create("https://test/kkk");
httpReq.ContentType = "text/xml";
httpReq.Method = "POST";
httpReq.KeepAlive=false;
byte[] requestbody = Encoding.UTF8.GetBytes("<test>kkk</test>");
Stream requestStream = httpReq.GetRequestStream();
int length = requestbody.Length;
requestStream.Write(requestbody,0,length);
requestStream.Close();
X509Certificate x509 = X509Certificate.CreateFromCertFile("C:\\kk\\509cer .cer");
ttpReq.ClientCertificates.Add(x509);
HttpWebResponse webResponse = (HttpWebResponse) httpReq.GetResponse();
}
catch (WebException ex)
{
Response.Write(ex.Message);
}
catch (Exception err)
{
Response.Write(err.Message);
}
 
Reply With Quote
 
 
 
 
Joe Kaplan \(MVP - ADSI\)
Guest
Posts: n/a
 
      05-11-2004
It is very likely an SSL problem. Do you seen any SChannel errors in the
event log? Do you get any certificate warnings when you do the same action
in the browser?

Oftentimes these errors can be overcome by creating a custom
ICertificatePolicy object that ignores the error you are getting, but it is
always better to solve the actual problem instead.

Joe K.

"Tom" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Dear all,
> when I ran the following code, I always got "The underlying connection

was closed: An unexpected error occurred on a send" error, it happend at
"httpReq.GetResponse();" and the stack trace is
> ************start of stack trace***************************
> The underlying connection was closed: An unexpected error occurred on a

send. at System.Net.HttpWebRequest.CheckFinalS
> tatus()
> at System.Net.HttpWebRequest.EndGetResponse(IAsyncRes ult asyncResult)
> at System.Net.HttpWebRequest.GetResponse()
> ***********end of stack trace**************88
> Much appreciated for any help!
> Tom
> ************************************************** **
> try
> {
> HttpWebRequest httpReq = (HttpWebRequest)

WebRequest.Create("https://test/kkk");
> httpReq.ContentType = "text/xml";
> httpReq.Method = "POST";
> httpReq.KeepAlive=false;
> byte[] requestbody = Encoding.UTF8.GetBytes("<test>kkk</test>");
> Stream requestStream = httpReq.GetRequestStream();
> int length = requestbody.Length;
> requestStream.Write(requestbody,0,length);
> requestStream.Close();
> X509Certificate x509 =

X509Certificate.CreateFromCertFile("C:\\kk\\509cer .cer");
> ttpReq.ClientCertificates.Add(x509);
> HttpWebResponse webResponse = (HttpWebResponse) httpReq.GetResponse();
> }
> catch (WebException ex)
> {
> Response.Write(ex.Message);
> }
> catch (Exception err)
> {
> Response.Write(err.Message);
> }



 
Reply With Quote
 
 
 
 
Tom
Guest
Posts: n/a
 
      05-13-2004
Thanks Joe, After analysing the problem, I found the the connection failed at the handshake phase, I modified the SSLwebclient SDK sample (security SSPI sample) and reproduce the problems. More specifically, it failed at InitializeSecurityContext with the error message "An unknown error happened when processing the certificate"
Now I am checking whether all the certificates were installed correctly

Tom
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
system.net.webexception The underlying connection was closed: An unexpected error occurred on a send. Rob Snell ASP .Net Web Services 5 09-28-2004 01:16 PM
Error when calling a web service (The underlying connection was closed: An unexpected error occurred on a receive.) Franck ASP .Net Web Services 0 11-12-2003 03:43 PM
The underlying connection was closed: An unexpected error occurred on a send Robert Walter ASP .Net Web Services 1 08-19-2003 03:34 PM
System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a send. Steven Harris ASP .Net Web Services 0 08-14-2003 10:23 AM
The underlying connection was closed: An unexpected error occurred on a send. Emre Aydinceren ASP .Net Web Services 4 08-07-2003 02:15 PM



Advertisments