473,403 Members | 2,270 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.

I'm working on shipping rate calculator going back and forth via XML. The
thing I'm confused about is that the code works, but after a few hours and I
don't know how many requests, I start getting the error "The underlying
connection was closed: Could not establish trust relationship for the
SSL/TLS secure channel." I can't imagine UPS's certificate is bad.

Here's my code, let me know if you see any glaring issues.

HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create(upsRateUri);
myReq.Headers.Clear();
myReq.Method = "POST";
myReq.ContentType = "application/x-www-form-urlencoded";
myReq.ContentLength = xmlString.Length;
StreamWriter sendingData = new StreamWriter(myReq.GetRequestStream());
sendingData.Write(xmlString);
sendingData.Close();
WebResponse myResponse = myReq.GetResponse();

Apr 19 '07 #1
4 21610
My guess would be that you do not close Streams/Requests properly and at
some time system runs out of them.
Be very careful with lines like that
StreamWriter sendingData = new StreamWriter(myReq.GetRequestStream());

That is big problem with .NET (unfortunately). No ownership. Who is
responsible for closing the Stream returned by myReq.GetRequestStream().

Who told you that StreamWrite will close the underlying Stream? Actually my
feeling from documentation it will not. All it will do just Flush own
buffers and resets it's state.

Again, i am not sure that this is your problem but usually if something
works for couple hours and then stops that means you run out of some kind of
system resources.
George

"Joel Barsotti" <jo***@stocklayouts.comwrote in message
news:ec**************@TK2MSFTNGP05.phx.gbl...
I'm working on shipping rate calculator going back and forth via XML. The
thing I'm confused about is that the code works, but after a few hours and
I don't know how many requests, I start getting the error "The underlying
connection was closed: Could not establish trust relationship for the
SSL/TLS secure channel." I can't imagine UPS's certificate is bad.

Here's my code, let me know if you see any glaring issues.

HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create(upsRateUri);
myReq.Headers.Clear();
myReq.Method = "POST";
myReq.ContentType = "application/x-www-form-urlencoded";
myReq.ContentLength = xmlString.Length;
StreamWriter sendingData = new StreamWriter(myReq.GetRequestStream());
sendingData.Write(xmlString);
sendingData.Close();
WebResponse myResponse = myReq.GetResponse();

Apr 19 '07 #2
Yeah I was starting to suspect that may be the case.

"George Ter-Saakov" <gt****@cardone.comwrote in message
news:eE**************@TK2MSFTNGP06.phx.gbl...
My guess would be that you do not close Streams/Requests properly and at
some time system runs out of them.
Be very careful with lines like that
StreamWriter sendingData = new StreamWriter(myReq.GetRequestStream());

That is big problem with .NET (unfortunately). No ownership. Who is
responsible for closing the Stream returned by myReq.GetRequestStream().

Who told you that StreamWrite will close the underlying Stream? Actually
my feeling from documentation it will not. All it will do just Flush own
buffers and resets it's state.

Again, i am not sure that this is your problem but usually if something
works for couple hours and then stops that means you run out of some kind
of system resources.
George

"Joel Barsotti" <jo***@stocklayouts.comwrote in message
news:ec**************@TK2MSFTNGP05.phx.gbl...
>I'm working on shipping rate calculator going back and forth via XML. The
thing I'm confused about is that the code works, but after a few hours
and I don't know how many requests, I start getting the error "The
underlying connection was closed: Could not establish trust relationship
for the SSL/TLS secure channel." I can't imagine UPS's certificate is
bad.

Here's my code, let me know if you see any glaring issues.

HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create(upsRateUri);
myReq.Headers.Clear();
myReq.Method = "POST";
myReq.ContentType = "application/x-www-form-urlencoded";
myReq.ContentLength = xmlString.Length;
StreamWriter sendingData = new StreamWriter(myReq.GetRequestStream());
sendingData.Write(xmlString);
sendingData.Close();
WebResponse myResponse = myReq.GetResponse();

Apr 19 '07 #3
HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create(upsRateUri);
myReq.Headers.Clear();
myReq.Method = "POST";
myReq.ContentType = "application/x-www-form-urlencoded";
myReq.ContentLength = xmlString.Length;

using(StreamWriter sendingData = new
StreamWriter(myReq.GetRequestStream()))
{
sendingData.Write(xmlString);
sendingData.Flush();
}

WebResponse myResponse = myReq.GetResponse();

On Apr 19, 11:07 am, "Joel Barsotti" <j...@stocklayouts.comwrote:
I'm working on shipping rate calculator going back and forth via XML. The
thing I'm confused about is that the code works, but after a few hours and I
don't know how many requests, I start getting the error "The underlying
connection was closed: Could not establish trust relationship for the
SSL/TLS secure channel." I can't imagine UPS's certificate is bad.

Here's my code, let me know if you see any glaring issues.

HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create(upsRateUri);
myReq.Headers.Clear();
myReq.Method = "POST";
myReq.ContentType = "application/x-www-form-urlencoded";
myReq.ContentLength = xmlString.Length;
StreamWriter sendingData = new StreamWriter(myReq.GetRequestStream());
sendingData.Write(xmlString);
sendingData.Close();
WebResponse myResponse = myReq.GetResponse();

Apr 19 '07 #4
nope

HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create(upsRateUri);
myReq.Headers.Clear();
myReq.Method = "POST";
myReq.ContentType = "application/x-www-form-urlencoded";
myReq.ContentLength = xmlString.Length;
using (StreamWriter sendingData = new
StreamWriter(myReq.GetRequestStream()))
{
sendingData.Write(xmlString);
sendingData.Flush();
sendingData.Close();
}

WebResponse myResponse = myReq.GetResponse();
StreamReader responseStream = new StreamReader
(myResponse.GetResponseStream());
XmlDocument shippingXml = new XmlDocument();
shippingXml.LoadXml(responseStream.ReadToEnd());

responseStream.Close();
myResponse.Close();Still getting the "The underlying connection was closed: Could not establish
trust relationship for the SSL/TLS secure channel" error message, after a
period of time.

"carion1" <dd******@gmail.comwrote in message
news:11**********************@b58g2000hsg.googlegr oups.com...
HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create(upsRateUri);
myReq.Headers.Clear();
myReq.Method = "POST";
myReq.ContentType = "application/x-www-form-urlencoded";
myReq.ContentLength = xmlString.Length;

using(StreamWriter sendingData = new
StreamWriter(myReq.GetRequestStream()))
{
sendingData.Write(xmlString);
sendingData.Flush();
}

WebResponse myResponse = myReq.GetResponse();

On Apr 19, 11:07 am, "Joel Barsotti" <j...@stocklayouts.comwrote:
>I'm working on shipping rate calculator going back and forth via XML. The
thing I'm confused about is that the code works, but after a few hours
and I
don't know how many requests, I start getting the error "The underlying
connection was closed: Could not establish trust relationship for the
SSL/TLS secure channel." I can't imagine UPS's certificate is bad.

Here's my code, let me know if you see any glaring issues.

HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create(upsRateUri);
myReq.Headers.Clear();
myReq.Method = "POST";
myReq.ContentType = "application/x-www-form-urlencoded";
myReq.ContentLength = xmlString.Length;
StreamWriter sendingData = new StreamWriter(myReq.GetRequestStream());
sendingData.Write(xmlString);
sendingData.Close();
WebResponse myResponse = myReq.GetResponse();

Apr 19 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Randy | last post by:
Hello, I've got a Windows client app which hits a web service. The web service works fine unless I'm outside the firewall using a VPN connection. I know my VPN connection is working fine because I...
1
by: C.W. | last post by:
I am trying to connect to a remote server in order to perform an http post inside my asp.net page. However, I consistently get the following error: System.Net.Sockets.Socket.Receive(Byte...
26
by: Rajeev Tipnis | last post by:
http://support.microsoft.com/default.aspx?scid=kb;en- us;819450 Questions: 1) Is this patch (fix) applicable to the .NET 1.1 Framework as well? That is, if we have Framework 1.1 (On...
1
by: Rob Thompson | last post by:
Hi, We are using web services that are secured using SSL, everything works fine, but every now and then we get an error: >>START<< System.Net.WebException: The underlying connection was...
4
by: Matthew.DelVecchio | last post by:
hello, i am developing an ASP.NET web app that consumes a 3rd party vendor webservice. it is my first one so while ive done my homework, im not an expert on the matter. our partner's...
3
by: musosdev | last post by:
Hi guys I've got the following error on a project which is running locally on a vs2005 machine (built in webserver), trying to connect to my win2k3 server active directory. the error is... ...
5
by: Suresh | last post by:
Hi Guys I have Db2 server installed on remote server. i am connecting to that remote server by using VPN. I want to connect that remote DB2 server instance using my local machine DB2...
7
by: Jim Butler | last post by:
I have this error that is happening on all of our web servers (production included). It basically started occurring once we loaded 2005 sql client tools, asp.net 2.0 (and all related prerequistes)...
0
by: =?Utf-8?B?c2dPcmNoaWQ=?= | last post by:
I am creating a Windows forms application which uses WebRequest to download RSS feed. The application generates the following error. "The underlying connection was closed: An unexpected error...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.