all groups > dotnet web services > march 2006 >
You're in the

dotnet web services

group:

need help desperately. The underlying connection was closed:


need help desperately. The underlying connection was closed: Karl Prosser
3/8/2006 11:50:35 PM
dotnet web services:
i'm having a very strange problem, i've been fighting it for more than 3
weeks. I am using WSE 3.0 t ocall a third party website, but when i call a
method through the proxy object i get NO RESPONSE at all just this exception:

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

however if i take the EXACT SAME soap request and headers generated by the
webservice and enter it into a product like SoapScope, and run it there, i
get a response. (the url in here is the one i am having a problem with, if
anybody wants to experiment

HttpWebRequest myReq =

(HttpWebRequest)WebRequest.Create("https://www.tpvs.hmrc.gov.uk/dpsauthentication/dpsauthentication.jws");
myReq.GetResponse();


so i decided to go lower level, and just communicate with the site via a
HttpWebRequest or WebClient , (as if you go to the site with the browser
you;'ll get a HTML reply at least.. i just want SOME reply).. however even
simple things like the following give the same error.

WebClient wc = new WebClient();

wc.DownloadString("https://www.tpvs.hmrc.gov.uk/dpsauthentication/dpsauthentication.jws");

this leads me to believe the issue is at a much lower level than WSE 3.0, or
SOAP itself. but i don't know what to do. i've tried the advice on the
newsgroups for this error with .Keepalive to no avail. and also this


System.Net.ServicePointManager.ServerCertificateValidationCallback +=
delegate(object sender2, X509Certificate certificate,
X509Chain chain, SslPolicyErrors sslPolicyErrors)
{
MessageBox.Show("dude");
bool validationResult = true;
return validationResult;
};

but it never gets called.

in need of desperate help.
Karl Prosser

RE: need help desperately. The underlying connection was closed: Karl Prosser
3/10/2006 11:12:27 AM
the plot thickens, even when its not a websevice (there is another service
provided by the same place which you just submit POST stuff https and i get
the same errors)

:(
i really need help.
here is a snippet:
HttpWebRequest myReq =

(HttpWebRequest)WebRequest.Create("https://www.tpvs.hmrc.gov.uk/EOY/post.slt");
myReq.KeepAlive = true;
myReq.Method = "POST";
myReq.ContentType = "txt/xml; charset=utf-8";
myReq.Timeout = 10000;
//myReq.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; MS Web
Services Client Protocol 2.0.50727.42) (Mindreef SOAPscope 4.1.12095)";
UTF8Encoding encoding = new UTF8Encoding();
byte[] byte1 = encoding.GetBytes (textBox1.Text);

Stream requeststream = myReq.GetRequestStream();
requeststream.Write(byte1, 0, byte1.Length);
requeststream.Close();

WebResponse myResponse = myReq.GetResponse();

its all good until the last line, where i get the same error.


RE: need help desperately. The underlying connection was closed: Karl Prosser
3/10/2006 4:39:26 PM
I've narrowed it down any further.

the httpwebclient and webclient BOTH work fine, without this error on dotnet
1.1 in visual studio 2003, but fail miserably with this error on visual
studio 2005, i don't know if this is a bug of the dotnet 2.0 framework, the
webservice provider not implementing a protocol as strict as it should be, or
a setting i can set to override this behaviour.

Re: need help desperately. The underlying connection was closed: klumsy NO[at]SPAM xtra.co.nz
3/15/2006 12:26:19 PM

microsoft support helped me solve this problem. The problem in essence
was the maker of the server code , did not specify which SSL protocol
they were using, and with dotnet 2.0 the dfeault is TLS, while the
server was actually using SSL3..

so basically what i had to do, is before creating any of the
communication objects run this line of code
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;

which in essence specifies the security protocol at a low level
(sockets) level, so it works no matter whether tie client object you
are using is a httpwebrequest, webclient , or webservice proxy class
generated by visual studio , or web services security extention 3
(WSE3) as is in my case.
I hope that putting this post out there, may help some other frustrated
coder in the future.
Re: need help desperately. The underlying connection was closed: Rob Taylor
3/19/2006 7:23:57 AM
Wow! I have just been having the EXACT SAME PROBLEM, with the EXACT
SAME SERVICE (DPS).

Feel free to email me directly if you have other issues that I may be
able to help you with. I owe you one.
AddThis Social Bookmark Button