Hi all,
I have problem when I use HttpWebRequest and take long time to call to my
service server. If at that time there are many request comes in
semultaneous, I will get this exception
System.Net.WebException: The underlying connection was closed: The request
was canceled. ---> System.IO.IOException: Unable to read data from the
transport connection. ---> System.ObjectDisposedException: Cannot access a
disposed object named "System.Net.TlsStream".
Object name: "System.Net.TlsStream".
at System.Net.Sockets.NetworkStream.EndRead(IAsyncRes ult asyncResult)
at System.Net.TlsStream.AsyncReceiveComplete(IAsyncRe sult result)
--- End of inner exception stack trace ---
at System.Net.TlsStream.EndRead(IAsyncResult asyncResult)
at System.Net.Connection.ReadCallback(IAsyncResult asyncResult)
--- End of inner exception stack trace ---
at System.Net.HttpWebRequest.CheckFinalStatus()
at System.Net.HttpWebRequest.EndGetResponse(IAsyncRes ult asyncResult)
at System.Net.HttpWebRequest.GetResponse()
at MFEC.DealerServices.Service.PaymentGateway.CallPay mentGateway(String
serviceName, GeneralParameterCollection inputParam)
Does anybody know how to solve this problem ? 5 5847
Hi,
The problem is that your proxy is not allowing the webrequest.
Do one thing create a webproxy object with your proxy name and port and
bind it to webrequest like this.
// True is to by pass proxy for local
WebProxy proxy = new WebProxy(name:port, true);
// suppose req is HttpWebRequest object
req.Proxy = proxy;
and then user req.getResponse method to get the response.
Regards,
Angrez
Hi singh_angrez,
Thank you for your suggestion. But I can test it in next 2 day after this
weekend. After I try I will report the result again if it can solve my
problem or not
Thank you very much
Jap.
Hi singh_angrez,
Before I try your suggestion. I wanna show you about my code.
And my server architecture is like this
Web server ----httprequest call to --> My service server
Actually, If my service server reponse the result to me in a short time,
everything is ok..no exception. But anytime my service server take long
time to process and send me the result.. at that time if there are many
requests from web server call to my service server, I got that exception
until my service server have a good response.
This is my code now. May be my code is not correct about HttpWebRequest
property.
//==== set ssl connection ==
ServicePointManager.CertificatePolicy = new MyPolicy();
HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create
(PAYMENTGATEWAY_URL+strParam.ToString());
objRequest.Method = "GET";
//==== add new code ==
objRequest.KeepAlive = false;
objRequest.ProtocolVersion=HttpVersion.Version10;
objRequest.Proxy = System.Net.WebProxy.GetDefaultProxy(); // I use
default proxy which work well in normal time.
objRequest.AllowAutoRedirect=true;
objRequest.MaximumAutomaticRedirections=10;
objRequest.Timeout = (int) new TimeSpan(0,0,HTTPTIMEOUT)
..TotalMilliseconds; // ,HTTPTIMEOUT = 300
objRequest.UserAgent="Mozilla/3.0 (compatible; My Browser/1.0)";
//==== add new code ==
string str = null;
HttpWebResponse objResponse;
StreamReader sr = null;
try
{
objResponse = (HttpWebResponse)objRequest.GetResponse();
}
catch( Exception e)
{
EventMgmt.EventExceptionMsg("Payment Gateway-GetResponse() =>
"+e.ToString(), @"\DataAccess\PGWException");
throw new ServiceException("PGW001","HOST_UNREACHABLE",e);
}
try
{
sr = new StreamReader(objResponse.GetResponseStream());
str = sr.ReadToEnd().Replace('\n'.ToString(),"").Replace ('\t'.ToString()
,"").Replace('&'.ToString(),"");
}
catch( Exception e)
{
EventMgmt.EventExceptionMsg("Payment Gateway-ReadResponseStream() =>
"+e.ToString(), @"\DataAccess\PGWException");
throw new ServiceException("PGW003","READ_STREAM_ERROR",e);
}
finally
{
if( sr != null)
sr.Close();
objResponse.Close();
}
Thank you,
Jap.
Have you seen this? http://support.microsoft.com/default...b;en-us;884537
- slightly different scenario, but you might be hitting the same bug.
--
Scott http://www.OdeToCode.com/blogs/scott/
On Fri, 22 Apr 2005 10:10:02 GMT, "japslam japslam via
DotNetMonster.com" <fo***@nospam.DotNetMonster.com> wrote: Hi all,
I have problem when I use HttpWebRequest and take long time to call to my service server. If at that time there are many request comes in semultaneous, I will get this exception
System.Net.WebException: The underlying connection was closed: The request was canceled. ---> System.IO.IOException: Unable to read data from the transport connection. ---> System.ObjectDisposedException: Cannot access a disposed object named "System.Net.TlsStream". Object name: "System.Net.TlsStream". at System.Net.Sockets.NetworkStream.EndRead(IAsyncRes ult asyncResult) at System.Net.TlsStream.AsyncReceiveComplete(IAsyncRe sult result) --- End of inner exception stack trace --- at System.Net.TlsStream.EndRead(IAsyncResult asyncResult) at System.Net.Connection.ReadCallback(IAsyncResult asyncResult) --- End of inner exception stack trace --- at System.Net.HttpWebRequest.CheckFinalStatus() at System.Net.HttpWebRequest.EndGetResponse(IAsyncRes ult asyncResult) at System.Net.HttpWebRequest.GetResponse() at MFEC.DealerServices.Service.PaymentGateway.CallPay mentGateway(String serviceName, GeneralParameterCollection inputParam)
Does anybody know how to solve this problem ?
the default setting for webclient is to only allow two connections to a
remote server. if you calls are slow, and they stack up, you will have
timeout problems. also you could hit your max thread pool sizes.
try upping the number of connections.
(httpRequest.ServicePoint.ConnectionLimit)
-- bruce (sqlwork.com)
"japslam japslam via DotNetMonster.com" <fo***@DotNetMonster.com> wrote in
message news:1b******************************@DotNetMonste r.com... Hi singh_angrez,
Before I try your suggestion. I wanna show you about my code. And my server architecture is like this
Web server ----httprequest call to --> My service server
Actually, If my service server reponse the result to me in a short time, everything is ok..no exception. But anytime my service server take long time to process and send me the result.. at that time if there are many requests from web server call to my service server, I got that exception until my service server have a good response.
This is my code now. May be my code is not correct about HttpWebRequest property.
//==== set ssl connection == ServicePointManager.CertificatePolicy = new MyPolicy();
HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create (PAYMENTGATEWAY_URL+strParam.ToString()); objRequest.Method = "GET";
//==== add new code == objRequest.KeepAlive = false; objRequest.ProtocolVersion=HttpVersion.Version10; objRequest.Proxy = System.Net.WebProxy.GetDefaultProxy(); // I use default proxy which work well in normal time. objRequest.AllowAutoRedirect=true; objRequest.MaximumAutomaticRedirections=10; objRequest.Timeout = (int) new TimeSpan(0,0,HTTPTIMEOUT) .TotalMilliseconds; // ,HTTPTIMEOUT = 300 objRequest.UserAgent="Mozilla/3.0 (compatible; My Browser/1.0)"; //==== add new code ==
string str = null; HttpWebResponse objResponse; StreamReader sr = null; try { objResponse = (HttpWebResponse)objRequest.GetResponse();
} catch( Exception e) { EventMgmt.EventExceptionMsg("Payment Gateway-GetResponse() => "+e.ToString(), @"\DataAccess\PGWException");
throw new ServiceException("PGW001","HOST_UNREACHABLE",e); }
try { sr = new StreamReader(objResponse.GetResponseStream()); str = sr.ReadToEnd().Replace('\n'.ToString(),"").Replace ('\t'.ToString() ,"").Replace('&'.ToString(),""); } catch( Exception e) { EventMgmt.EventExceptionMsg("Payment Gateway-ReadResponseStream() => "+e.ToString(), @"\DataAccess\PGWException");
throw new ServiceException("PGW003","READ_STREAM_ERROR",e); } finally { if( sr != null) sr.Close(); objResponse.Close(); } Thank you,
Jap. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Gregory A Greenman |
last post by:
I'm trying to write a program in vb.net to automate filling out a
series of forms on a website. There are three forms I need to
fill out in sequence. The first one is urlencoded. My program is...
|
by: Raj Chudasama |
last post by:
i have a need to load image from URL. the image is really small (gif) and i
use the following code.
but the code is too slow any1 have any alternative way(S)?
here is the url...
|
by: Jeff B |
last post by:
I'm trying to create a simple screen scraping application and I kept
getting a System.Net.WebException thrown back with a message of "The
operation has timed-out." At first I thought it was some...
|
by: Steve Richter |
last post by:
I have a page that uses simple HTTP GET to do an ISBN lookup via
Amazon.com. The page works when I run it from //localhost. But I have
moved it to my godaddy.com shared hoster site, and I get...
|
by: microdevsolutions |
last post by:
Hello
I've seen examples to read a file from somewhere into a HttpWebRequest
object then write it to a HttpWebResponse object then stream it into a
Stream object, very similar to the following...
|
by: mr.newsgroupguy |
last post by:
I am working in C# .NET 1.1. My app has a button on its main form that
checks to see if it has access to a file on our server, just an XML
file. On our server we are running W2K IIS with a...
|
by: Admin.TalkPC |
last post by:
Hi people,
I have now spent far too much time on this small problem, I am
hopefully going to hand it over to you guys that are cleverer than I in
this respect.
Problem. I need to get all...
|
by: ALA |
last post by:
Hi,
does anybody know if it is possible to pass the SessionID with a web
request by using a cookie so that the invoked page in the same domain
can access the session objects of the current user?...
|
by: =?Utf-8?B?SmltIE93ZW4=?= |
last post by:
Hi,
I've run into a set of errors I don't understand coming back from
HttpWebRequest.GetResponse, In one case, null is returned from the request
without an Exception and in the other the request...
|
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,...
|
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$) {
}
...
|
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...
|
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...
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
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...
| |