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

Https components throw the exception after the long idle time

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 https request after a long
period with no activity.

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.


Encoding oEnc = System.Text.Encoding.GetEncoding(1252);
oNc = new NetworkCredential(cUserName, cPassWord);

oWebReq = (HttpWebRequest) WebRequest.Create("https://...");
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
2 1610
SMike,

Are you closing the response stream? It doesn't appear that you are.
Perhaps this is the problem?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"SMike" <mm******@hotmail.com> wrote in message
news:eP*************@TK2MSFTNGP11.phx.gbl...
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 https request after a long
period with no activity.

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.


Encoding oEnc = System.Text.Encoding.GetEncoding(1252);
oNc = new NetworkCredential(cUserName, cPassWord);

oWebReq = (HttpWebRequest) WebRequest.Create("https://...");
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
Nicolas,

I do.

The problem is it fails once only after a long time with no activity. First
one fails - the rest of them would work fine until the next long idle
period.

Thank you,
Michael

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:%2****************@TK2MSFTNGP12.phx.gbl...
SMike,

Are you closing the response stream? It doesn't appear that you are.
Perhaps this is the problem?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"SMike" <mm******@hotmail.com> wrote in message
news:eP*************@TK2MSFTNGP11.phx.gbl...
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 https request after a long period with no activity.

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.


Encoding oEnc = System.Text.Encoding.GetEncoding(1252);
oNc = new NetworkCredential(cUserName, cPassWord);

oWebReq = (HttpWebRequest) WebRequest.Create("https://...");
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

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

Similar topics

8
by: Soeren S. Joergensen | last post by:
Hi, From a win-service I do a HttpWebRequest to a secure url with some parameters to get some simple data from a remote system used later on in a worker thread. When making the request from...
8
by: cat | last post by:
I had a long and heated discussion with other developers on my team on when it makes sense to throw an exception and when to use an alternate solution. The .NET documentation recommends that an...
2
by: Greg Wood | last post by:
As a new member, I hope I am posting correctly. Bear with me if not ! I found a posting by Earle Oxner that very closely matches the situation we are in. Sadly, there were no replies to his post,...
6
by: jason.cipriani | last post by:
Consider this program, which defines a template class who's template parameter is the type of an exception that can be thrown by members of the class: === BEGIN EXAMPLE === #include...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...

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.