473,395 Members | 1,689 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,395 software developers and data experts.

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 6685
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
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
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
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
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
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
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
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
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...

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.