Showing posts with label request. Show all posts
Showing posts with label request. Show all posts

Saturday, March 24, 2012

Please help ! Problem about HttpWebRequest - GetResponse()

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(IAsyncResult asyncResult)
at System.Net.TlsStream.AsyncReceiveComplete(IAsyncResult 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(IAsyncResult asyncResult)
at System.Net.HttpWebRequest.GetResponse()
at MFEC.DealerServices.Service.PaymentGateway.CallPaymentGateway(String
serviceName, GeneralParameterCollection inputParam)
Does anybody know how to solve this problem ?Have you seen this?
http://support.microsoft.com/defaul...kb;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
webservertalk.com" <forum@.nospam.webservertalk.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(IAsyncResult asyncResult)
> at System.Net.TlsStream.AsyncReceiveComplete(IAsyncResult 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(IAsyncResult asyncResult)
> at System.Net.HttpWebRequest.GetResponse()
> at MFEC.DealerServices.Service.PaymentGateway.CallPaymentGateway(String
>serviceName, GeneralParameterCollection inputParam)
>
>Does anybody know how to solve this problem ?

Please help ! Problem about HttpWebRequest - GetResponse()

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 ?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/defaul...kb;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" <forum@.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" <forum@.DotNetMonster.com> wrote in
message news:1b2e8e50a4a5493bbb9004d9c3d2c1f0@.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.

Wednesday, March 21, 2012

please help me on multiple update recordset

when i select 2 records to update from checkbox, it only updated 1 record. can anyone help me?

code
====

<%
if request("deleted")="" then
response.redirect"member.asp"
end if
set rs=server.createobject("ADODB.Recordset")
sql="select pause from Users where id IN ("&request("deleted")&")"
rs.open sql,cn,1,2
if not rs.eof then
rs("pause")="1"
rs.update
end if
rs.close
set rs=nothing
closeCN
%><script
javascript:document.location='member.asp';
</script
=======================================================Instead of if ... then go for

while not rs.eof
rs("pause")="1"
rs.update
rs.movenext
wend

:))
Devendra.
Thanks cdnaik
I't works.
:)

Friday, March 16, 2012

Please Help me understand..

I want to create a page that pulls a specific record from a database based on the value passed from a Request.QueryString. If the value is not in the string then it uses a default value of 1(one). Here is what I have so far:

' Determine if a Content ID has been passed in the query string
' If so use it as a variable in our SQL string to grab content for the page
' Httpcontext.Request.Querystring("Content_id")

Sub BindHomeBodyData() ' GRAB CONTENT *************************

Const strSQL as String = "SELECT * FROM Content WHERE Content_ID = " & Httpcontext.Request.Querystring("Content_id")
Dim myCommand as New SqlCommand(strSQL, myConnection)
Dim myDA as New SqlDataAdapter()
myDA.SelectCommand = myCommand
Dim myDS as New DataSet()
myDA.Fill(myDS)
dlHomeBodyData.DataSource = myDS
dlHomeBodyData.DataBind()

End SubNot tested:

Dim Content_ID As Integer = 1

If Not IsNull(Request.QueryString("Content_id")) Then
Dim myRegEx As New RegEx("[^0-9]"), sContent As String = myRegEx.Replace(Request.QueryString("Content_id"), "")

If sContent <> "" Then
Content_ID = CInt(sContent)
End If
End If


to take what you have given me and place it into what I have. Sorry I am an extreme newbie. Here is what I have is there any way you could educate me here and show me how to write this out according to my example. Thanks a lot I appreciate it.

Sub BindHomeBodyData() ' GRAB CONTENT *************************

Const strSQL as String = "SELECT * FROM Content WHERE Content_ID = " & Httpcontext.Request.Querystring("Content_id")
Dim myCommand as New SqlCommand(strSQL, myConnection)
Dim myDA as New SqlDataAdapter()
myDA.SelectCommand = myCommand
Dim myDS as New DataSet()
myDA.Fill(myDS)
dlHomeBodyData.DataSource = myDS
dlHomeBodyData.DataBind()

End Sub