473,586 Members | 2,490 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Cannot access a disposed object named "System.Net.Tls Stream".

I am getting the following error when sending a first http request:

Cannot access a disposed object named "System.Net.Tls Stream".

After that everything sems to be fine untill the next long idle period. The
code is below. Any helpful ideas would be appriciated.
Encoding oEnc = System.Text.Enc oding.GetEncodi ng(1252);
oNc = new NetworkCredenti al(cUserName, cPassWord);

oWebReq = (HttpWebRequest ) WebRequest.Crea te(cUrl);
oWebReq.Timeout = 30000;
oWebReq.Content Type = "text/xml";
oWebReq.Method = "POST";
oWebReq.Content Length = bBuffer.Length;

// -- request ---
oPostStream = oWebReq.GetRequ estStream();
oPostStream.Wri te(bBuffer,0,bB uffer.Length);
oPostStream.Clo se();

// -- response ---
oWebRes = (HttpWebRespons e) oWebReq.GetResp onse();

oResStream = new StreamReader(oW ebRes.GetRespon seStream(),oEnc );
cRes = oResStream.Read ToEnd();
Nov 16 '05 #1
5 6720
SMike,

Is the url a secure url perhaps? The TlsStream I believe, is used to
handle SSL socket connections (for HTTPS). Based on the code here, I can't
see anything that would cause this problem.

Can you work up a small example, with a live URL perhaps?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"SMike" <mm******@hotma il.com> wrote in message
news:uV******** ******@TK2MSFTN GP11.phx.gbl...
I am getting the following error when sending a first http request:

Cannot access a disposed object named "System.Net.Tls Stream".

After that everything sems to be fine untill the next long idle period.
The
code is below. Any helpful ideas would be appriciated.
Encoding oEnc = System.Text.Enc oding.GetEncodi ng(1252);
oNc = new NetworkCredenti al(cUserName, cPassWord);

oWebReq = (HttpWebRequest ) WebRequest.Crea te(cUrl);
oWebReq.Timeout = 30000;
oWebReq.Content Type = "text/xml";
oWebReq.Method = "POST";
oWebReq.Content Length = bBuffer.Length;

// -- request ---
oPostStream = oWebReq.GetRequ estStream();
oPostStream.Wri te(bBuffer,0,bB uffer.Length);
oPostStream.Clo se();

// -- response ---
oWebRes = (HttpWebRespons e) oWebReq.GetResp onse();

oResStream = new StreamReader(oW ebRes.GetRespon seStream(),oEnc );
cRes = oResStream.Read ToEnd();

Nov 16 '05 #2
Nicholas,

Thanks for a response. You are right - https is used. can't give you a
link - it's internal. I found such a problem is being discussed, but could
not find a solution.


"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c om> wrote in
message news:O5******** ******@TK2MSFTN GP15.phx.gbl...
SMike,

Is the url a secure url perhaps? The TlsStream I believe, is used to
handle SSL socket connections (for HTTPS). Based on the code here, I can't see anything that would cause this problem.

Can you work up a small example, with a live URL perhaps?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"SMike" <mm******@hotma il.com> wrote in message
news:uV******** ******@TK2MSFTN GP11.phx.gbl...
I am getting the following error when sending a first http request:

Cannot access a disposed object named "System.Net.Tls Stream".

After that everything sems to be fine untill the next long idle period.
The
code is below. Any helpful ideas would be appriciated.
Encoding oEnc = System.Text.Enc oding.GetEncodi ng(1252);
oNc = new NetworkCredenti al(cUserName, cPassWord);

oWebReq = (HttpWebRequest ) WebRequest.Crea te(cUrl);
oWebReq.Timeout = 30000;
oWebReq.Content Type = "text/xml";
oWebReq.Method = "POST";
oWebReq.Content Length = bBuffer.Length;

// -- request ---
oPostStream = oWebReq.GetRequ estStream();
oPostStream.Wri te(bBuffer,0,bB uffer.Length);
oPostStream.Clo se();

// -- response ---
oWebRes = (HttpWebRespons e) oWebReq.GetResp onse();

oResStream = new StreamReader(oW ebRes.GetRespon seStream(),oEnc );
cRes = oResStream.Read ToEnd();


Nov 16 '05 #3
SMike wrote:
I am getting the following error when sending a first http request:

Cannot access a disposed object named "System.Net.Tls Stream".

After that everything sems to be fine untill the next long idle period. The
code is below. Any helpful ideas would be appriciated.
Encoding oEnc = System.Text.Enc oding.GetEncodi ng(1252);
oNc = new NetworkCredenti al(cUserName, cPassWord);

oWebReq = (HttpWebRequest ) WebRequest.Crea te(cUrl);
oWebReq.Timeout = 30000;
oWebReq.Content Type = "text/xml";
oWebReq.Method = "POST";
oWebReq.Content Length = bBuffer.Length;

// -- request ---
oPostStream = oWebReq.GetRequ estStream();
oPostStream.Wri te(bBuffer,0,bB uffer.Length);
oPostStream.Clo se();

// -- response ---
oWebRes = (HttpWebRespons e) oWebReq.GetResp onse();

oResStream = new StreamReader(oW ebRes.GetRespon seStream(),oEnc );
cRes = oResStream.Read ToEnd();


Are you closing oResStream somewere? You must assure that
the stream is closed.

bye
Rob
Nov 16 '05 #4
Rod, I do that.

Could you tell if the following settings can cause such a behavior

ServicePointMan ager.MaxService Points = 15;
ServicePointMan ager.DefaultCon nectionLimit = 15;
ServicePointMan ager.MaxService PointIdleTime - how can this setting help?

Thanx in advance
Mike


"Robert Jordan" <ro*****@gmx.ne t> wrote in message
news:ci******** *****@news.t-online.com...
SMike wrote:
I am getting the following error when sending a first http request:

Cannot access a disposed object named "System.Net.Tls Stream".

After that everything sems to be fine untill the next long idle period. The code is below. Any helpful ideas would be appriciated.
Encoding oEnc = System.Text.Enc oding.GetEncodi ng(1252);
oNc = new NetworkCredenti al(cUserName, cPassWord);

oWebReq = (HttpWebRequest ) WebRequest.Crea te(cUrl);
oWebReq.Timeout = 30000;
oWebReq.Content Type = "text/xml";
oWebReq.Method = "POST";
oWebReq.Content Length = bBuffer.Length;

// -- request ---
oPostStream = oWebReq.GetRequ estStream();
oPostStream.Wri te(bBuffer,0,bB uffer.Length);
oPostStream.Clo se();

// -- response ---
oWebRes = (HttpWebRespons e) oWebReq.GetResp onse();

oResStream = new StreamReader(oW ebRes.GetRespon seStream(),oEnc );
cRes = oResStream.Read ToEnd();


Are you closing oResStream somewere? You must assure that
the stream is closed.

bye
Rob

Nov 16 '05 #5
sorry for too many messages. I was getting errors while sending them.
"SMike" <mm******@hotma il.com> wrote in message
news:uV******** ******@TK2MSFTN GP11.phx.gbl...
I am getting the following error when sending a first http request:

Cannot access a disposed object named "System.Net.Tls Stream".

After that everything sems to be fine untill the next long idle period. The code is below. Any helpful ideas would be appriciated.
Encoding oEnc = System.Text.Enc oding.GetEncodi ng(1252);
oNc = new NetworkCredenti al(cUserName, cPassWord);

oWebReq = (HttpWebRequest ) WebRequest.Crea te(cUrl);
oWebReq.Timeout = 30000;
oWebReq.Content Type = "text/xml";
oWebReq.Method = "POST";
oWebReq.Content Length = bBuffer.Length;

// -- request ---
oPostStream = oWebReq.GetRequ estStream();
oPostStream.Wri te(bBuffer,0,bB uffer.Length);
oPostStream.Clo se();

// -- response ---
oWebRes = (HttpWebRespons e) oWebReq.GetResp onse();

oResStream = new StreamReader(oW ebRes.GetRespon seStream(),oEnc );
cRes = oResStream.Read ToEnd();

Nov 16 '05 #6

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

Similar topics

0
339
by: Asaf | last post by:
Hi, When I am doing a POST to a SSL URL I am getting this error on first attempt "Cannot access a disposed object named "System.Net.TlsStream"." After the first attempt all works fine, here is the Stack Trace at System.Net.TlsStream.InnerWrite(Boolean async, Byte buffer, Int32 offset, Int32 size, AsyncCallback asyncCallback, Object...
2
351
by: SMike | last post by:
I post this message again as I didn't get an answer back. I would appriciate any ideas. I am getting the following error when sending a first https request: Cannot access a disposed object named "System.Net.TlsStream". After that everything sems to be fine untill the next long idle period. The code is below.
2
1335
by: Asaf | last post by:
Hi All, When doing HTTP POST to SSL URL I am getting the error: Cannot access a disposed object named "System.Net.TlsStream". I have found this code in the internet but it does not solve the problem. internal class AcceptAllCertificatePolicy : ICertificatePolicy {
2
3417
by: =?Utf-8?B?cmVk?= | last post by:
Hi Friends, We recently deployed our application to production and I am experiencing the below error message. Cannot access a disposed object named "System.Net.TlsStream" The error occurs when we are making a web service call to an external system (within our corporate n/w). The method is POST and the URL is over HTTPS.
0
240
by: Ronald S. Cook | last post by:
I'm just curious how you would handle this. In the cable industry, Comcast is referred to as an "MSO" (multiple systems operator) meaning they own many cable systems. Therefore a solution must be architected to accommodate "System" as an entity. This means a table in the database named System, a class System, a web form System, etc. ...
5
1639
by: Chris Botha | last post by:
There is a database table with one of the columns named "System". When creating a new Dataset for this table, the project gives a huge number of compile errors. If I change the column name to be anything else than "System" and re-generate the Dataset, it works. The problem is that this is an existing database and there is no way that the...
4
1484
by: Chris Botha | last post by:
The customer has a database with a column in a table named "System". I've been using this method for years now - create a dataset (an .xsd file) for the table. With a column named "System" in the dataset, it gives a substantial number of compile errors. To simplify the problem, add a Dataset with one table and one column called "System" -...
0
7915
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8204
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8339
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7965
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
3838
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3869
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2345
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1452
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1184
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.