473,790 Members | 2,629 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 6742
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 asyncState) at System.Net.TlsStream.BeginWrite(Byte buffer, Int32 offset, Int32 size, AsyncCallback...
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
1351
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
3447
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. Since System is such a reserved word, how should we do this? To rename it "CableSystem" would bug as...
5
1662
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 column name will be changed.
4
1496
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" - below follows how it can be done: Right click on the solution, click "Add", click "New Item" and...
0
9666
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9512
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10413
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9021
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7530
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6769
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4094
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
2
3707
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2909
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.