473,499 Members | 1,579 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Cannot access a disposed object named "System.Net.TlsStream".

I am getting the following error when sending a first http 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. Any helpful ideas would be appriciated.
Encoding oEnc = System.Text.Encoding.GetEncoding(1252);
oNc = new NetworkCredential(cUserName, cPassWord);

oWebReq = (HttpWebRequest) WebRequest.Create(cUrl);
oWebReq.Timeout = 30000;
oWebReq.ContentType = "text/xml";
oWebReq.Method = "POST";
oWebReq.ContentLength = bBuffer.Length;

// -- request ---
oPostStream = oWebReq.GetRequestStream();
oPostStream.Write(bBuffer,0,bBuffer.Length);
oPostStream.Close();

// -- response ---
oWebRes = (HttpWebResponse) oWebReq.GetResponse();

oResStream = new StreamReader(oWebRes.GetResponseStream(),oEnc);
cRes = oResStream.ReadToEnd();
Nov 16 '05 #1
5 6696
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.com

"SMike" <mm******@hotmail.com> wrote in message
news:uV**************@TK2MSFTNGP11.phx.gbl...
I am getting the following error when sending a first http 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. Any helpful ideas would be appriciated.
Encoding oEnc = System.Text.Encoding.GetEncoding(1252);
oNc = new NetworkCredential(cUserName, cPassWord);

oWebReq = (HttpWebRequest) WebRequest.Create(cUrl);
oWebReq.Timeout = 30000;
oWebReq.ContentType = "text/xml";
oWebReq.Method = "POST";
oWebReq.ContentLength = bBuffer.Length;

// -- request ---
oPostStream = oWebReq.GetRequestStream();
oPostStream.Write(bBuffer,0,bBuffer.Length);
oPostStream.Close();

// -- response ---
oWebRes = (HttpWebResponse) oWebReq.GetResponse();

oResStream = new StreamReader(oWebRes.GetResponseStream(),oEnc);
cRes = oResStream.ReadToEnd();

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.com> wrote in
message news:O5**************@TK2MSFTNGP15.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.com

"SMike" <mm******@hotmail.com> wrote in message
news:uV**************@TK2MSFTNGP11.phx.gbl...
I am getting the following error when sending a first http 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. Any helpful ideas would be appriciated.
Encoding oEnc = System.Text.Encoding.GetEncoding(1252);
oNc = new NetworkCredential(cUserName, cPassWord);

oWebReq = (HttpWebRequest) WebRequest.Create(cUrl);
oWebReq.Timeout = 30000;
oWebReq.ContentType = "text/xml";
oWebReq.Method = "POST";
oWebReq.ContentLength = bBuffer.Length;

// -- request ---
oPostStream = oWebReq.GetRequestStream();
oPostStream.Write(bBuffer,0,bBuffer.Length);
oPostStream.Close();

// -- response ---
oWebRes = (HttpWebResponse) oWebReq.GetResponse();

oResStream = new StreamReader(oWebRes.GetResponseStream(),oEnc);
cRes = oResStream.ReadToEnd();


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.TlsStream".

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.Encoding.GetEncoding(1252);
oNc = new NetworkCredential(cUserName, cPassWord);

oWebReq = (HttpWebRequest) WebRequest.Create(cUrl);
oWebReq.Timeout = 30000;
oWebReq.ContentType = "text/xml";
oWebReq.Method = "POST";
oWebReq.ContentLength = bBuffer.Length;

// -- request ---
oPostStream = oWebReq.GetRequestStream();
oPostStream.Write(bBuffer,0,bBuffer.Length);
oPostStream.Close();

// -- response ---
oWebRes = (HttpWebResponse) oWebReq.GetResponse();

oResStream = new StreamReader(oWebRes.GetResponseStream(),oEnc);
cRes = oResStream.ReadToEnd();


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

ServicePointManager.MaxServicePoints = 15;
ServicePointManager.DefaultConnectionLimit = 15;
ServicePointManager.MaxServicePointIdleTime - how can this setting help?

Thanx in advance
Mike


"Robert Jordan" <ro*****@gmx.net> 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.TlsStream".

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.Encoding.GetEncoding(1252);
oNc = new NetworkCredential(cUserName, cPassWord);

oWebReq = (HttpWebRequest) WebRequest.Create(cUrl);
oWebReq.Timeout = 30000;
oWebReq.ContentType = "text/xml";
oWebReq.Method = "POST";
oWebReq.ContentLength = bBuffer.Length;

// -- request ---
oPostStream = oWebReq.GetRequestStream();
oPostStream.Write(bBuffer,0,bBuffer.Length);
oPostStream.Close();

// -- response ---
oWebRes = (HttpWebResponse) oWebReq.GetResponse();

oResStream = new StreamReader(oWebRes.GetResponseStream(),oEnc);
cRes = oResStream.ReadToEnd();


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******@hotmail.com> wrote in message
news:uV**************@TK2MSFTNGP11.phx.gbl...
I am getting the following error when sending a first http 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. Any helpful ideas would be appriciated.
Encoding oEnc = System.Text.Encoding.GetEncoding(1252);
oNc = new NetworkCredential(cUserName, cPassWord);

oWebReq = (HttpWebRequest) WebRequest.Create(cUrl);
oWebReq.Timeout = 30000;
oWebReq.ContentType = "text/xml";
oWebReq.Method = "POST";
oWebReq.ContentLength = bBuffer.Length;

// -- request ---
oPostStream = oWebReq.GetRequestStream();
oPostStream.Write(bBuffer,0,bBuffer.Length);
oPostStream.Close();

// -- response ---
oWebRes = (HttpWebResponse) oWebReq.GetResponse();

oResStream = new StreamReader(oWebRes.GetResponseStream(),oEnc);
cRes = oResStream.ReadToEnd();

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...
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...
2
1332
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...
2
3395
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...
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...
5
1629
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...
4
1481
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...
0
7007
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
7171
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
7220
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...
1
6893
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...
0
7386
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
5468
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,...
1
4918
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...
0
3090
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1427
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 ...

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.