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

expert Help Please HttpWebResponse --The operation has timed-out.

Tom
Hi, Could someone please help me with this

I am trying to do use the following code to post a form and get
response but it 's keep giving me a error "The operation has
timed-out." on this line

oRespons = CType(oRequest.GetResponse(), HttpWebResponse)

I have to us Unicode Encoding so it knows national charactor.

Please help how can i make this work

here is the code

Public Function DoHttpRequest(ByVal strWWWAddress As String, ByVal
strdata As String, ByRef strResult As String, ByRef iStatusCode As
HttpStatusCode) As Boolean
Dim bolReturn As Boolean

Dim strMethodName As String

strResult = ""

iStatusCode = HttpStatusCode.Unused

Dim timeRequestStart As DateTime = DateTime.Now

Dim oRequest As HttpWebRequest = Nothing

Dim oInStream As Stream = Nothing

Dim oRespons As HttpWebResponse = Nothing

Dim readStream As StreamReader = Nothing

Dim oEncoding As Encoding = Encoding.Unicode

Try
Dim bSendData As Boolean

strMethodName = "POST"

oRequest = CType(WebRequest.Create(strWWWAddress),
HttpWebRequest)

oRequest.Method = strMethodName
oRequest.ContentType = "application/x-www-form-urlencoded"
oRequest.ServicePoint.Expect100Continue = False
oRequest.Timeout = 10 * 1000
' oRequest.Credentials = New NetworkCredential("UserName",
"Password")
oRequest.ServicePoint.ConnectionLimit = 15

If bSendData Then

oInStream = oRequest.GetRequestStream()

Dim data As Byte() = oEncoding.GetBytes(strdata)

oInStream.Write(data, 0, data.Length)

oInStream.Flush()

oInStream.Close()
oInStream = Nothing
End If

oRespons = CType(oRequest.GetResponse(), HttpWebResponse)

readStream = New StreamReader(oRespons.GetResponseStream(),
Encoding.Unicode)

strResult = readStream.ReadToEnd()

readStream.Close()
readStream = Nothing

iStatusCode = oRespons.StatusCode

oRespons.Close()
oRespons = Nothing

bolReturn = True
Catch ex As Exception

' Me.EmailAdmin(ex.Message, ex.StackTrace)
'bolReturn = False
Finally

If Not (oInStream Is Nothing) Then
oInStream.Close()
End If
If Not (readStream Is Nothing) Then
readStream.Close()
End If
If Not (oRespons Is Nothing) Then
oRespons.Close()
End If
End Try

Return bolReturn
End Function 'DoHttpRequest
to call this function

in form_load
Dim param As Byte() =
HttpContext.Current.Request.BinaryRead(HttpContext .Current.Request.ContentLength)
Dim ps As String = Encoding.Unicode.GetString(param)

ps += "&cmd=_notify-validate"

Dim status As System.Net.HttpStatusCode

If DoHttpRequest("https://www.paypal.com/cgi-bin/webscr",
ps, strResponse, status) = False Then
' do insert to DB
end if

-------------------------------------------------------------------------------------------------------
please reply to my email becasue i had a hard time finding what i
posted so i had to repost again, my email is me******@hotmail.com

Thank you

Nov 29 '06 #1
0 1436

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

Similar topics

1
by: laks | last post by:
Hi all I have the following piece of code for retrieving some info from an external url. I receive an error - "The operation has timed-out" at GetResponse() line. I have tried extending the time...
1
by: | last post by:
I am performing several httpwebrequest and webresponse operations to download some wav files. I included the sample code below. When I execute these commands they work for a while and then 5 -...
0
by: yariv | last post by:
Hello All, I am having a very strange problem. while trying to access http page on the web. I happen to have some problems at specific machines. the exception I get is: *************...
0
by: Matt | last post by:
(can't find any of my previous post for same issue. please CC to my email address as well. Thanks!) Hi all, What is the possible reason that HttpWebRequest.GetRequestStream() may hang there...
5
by: Sachin Surana | last post by:
We use HttpWebRequest to send the request at a URL. But some times the method GetResponse throws a time out exception. But when we check the IIS logs, there is no such entry. So the request never...
4
by: VB Programmer | last post by:
When I run my ASP.NET 2.0 web app on my dev machine it works perfect. When I precomile it to my web deployment project and then copy the debug files to my web server I get this problem when trying...
1
by: Andy Chen | last post by:
Hi all, Please help me to look at the following code, I always get a 'The operation has timed-out.' exception. But the URL can be opened in IE properly. I am wondering if I missed some code. Any...
1
by: goal2007 | last post by:
I was getting SQLException Time out so i added this line cmd.CommandTimeout = 1000; also in my ScriptManager i set AsyncPostBackTimeout="1200". now when i run my application all what i get is this...
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: 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
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?
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
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.