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

HttpWebRequest The operation has timed-out

Hi,

I have an ASP.NET 1.1 app running on Windows XP SP2 that is requesting
information from a WebService which works just fine. Another part of the app
is doing a server-side post to antoher system using HttpWebRequest. Code as
follows:

==============================
Dim objWebReq As HttpWebRequest
Dim objStream As Stream
Dim strData As String
Dim arrPostArray As Byte()

'Construct form data
strData = "field1=x&field2=y"
arrPostArray = System.Text.Encoding.ASCII.GetBytes(strData)

objWebReq = WebRequest.Create("http://www.xx.yy/page.aspx")
objWebReq.Method = "POST"
objWebReq.KeepAlive = False
objWebReq.ContentType = "application/x-www-form-urlencoded"
objWebReq.ContentLength = arrPostArray.Length

'Maintain between state calls
If Not Session("comsess") Is Nothing Then
objWebReq.CookieContainer = CType(Session("comsess"),
System.Net.CookieContainer)
End If

objStream = objWebReq.GetRequestStream
objStream.Write(arrPostArray, 0, arrPostArray.Length)
objStream.Close
==============================

This works fine but suddenly subsequent WebService calls bombs out with:

==============================
System.Net.WebException: The operation has timed-out.

Line 47: Dim results() As Object = Me.Invoke("RetrieveData", New Object()
{strArg1, strArg2})
==============================

Feels like something doesn't get closed in the HttpWebRequest and clogs up
the following WebService call. I can't find any method to close it with. KB
http://support.microsoft.com/kb/821268 is talking about this problem but it
happens after just one post and it feels like something else goes wrong. The
reason we're using HttpWebRequest instead of WebClient is because WebClient
doesn't support CookieContainer.

I'm really grateful for any and all help with this issue.

Many thanks,
Manso

Nov 19 '05 #1
1 5799
Ok, I found the solution (which wasn't obvious). The problem is that I didn't
take care of and closed the response stream. Adding these lines:

objWebRes = objWebReq.GetResponse
objWebRes.Close

at the end made it work. The confusing thing here is that many of the
examples in the HttpWebRequest documentation are faulty, e.g.

http://msdn.microsoft.com/library/de...asp?frame=true

Solution found thanks to:

http://blogs.msdn.com/feroze_daud/ar.../21/61400.aspx

Regards,
Manso
Nov 19 '05 #2

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

Similar topics

1
by: poi | last post by:
I want to do an HTTP "GET" against a remote web server, and make sure that I get data back with gzip so the transfer is as fast as possible. It seems like gzip encoding only works with a "POST",...
16
by: thomas peter | last post by:
I am building a precache engine... one that request over 100 pages on an remote server to cache them remotely... can i use the HttpWebRequest and WebResponse classes for this? or must i use the...
2
by: Javaman59 | last post by:
I have a GUI which is monitoring a real-time device. I have several timed actions, such as periodic polling of the device, and indicators which flash for a fixed period. My first implementation...
1
by: | last post by:
I have a strange behavior of a following code: HttpWebRequest request=(HttpWebRequest)WebRequest.Create(@"http://.../target.jsp"); request.ProtocolVersion=HttpVersion.Version11;...
1
by: sfoxover | last post by:
Hi, Could someone please give me some suggestions on how to make this class robust. I need to be able to handle around 20 similtanious requests to this class which causes a web browser to...
6
by: Mike Koerner | last post by:
Hi, I am having problems setting the HttpWebRequest Date header. I understand that it is a restricted header and I do receive the "This header must be modified with the appropriate property." ...
0
by: Norb | last post by:
Hello i keep gettign this error when i use this code Error: An unhandled exception of type 'System.Net.Sockets.SocketException' occurred in system.dll Additional information: An operation on...
1
by: Assaf Shemesh | last post by:
Hi, I'm having a problem with asynchronous HttpWebRequest. It's a simple http client-server. For most of my users it works fine. However, some of them get the exception: ...
3
by: JansenH | last post by:
We have implemented a 'HTTP Post' client in C# that posts Xml documents to a webserver. This is working fine if the post rate is one post for every 20 seconds. But if the post rate is increased to...
1
by: tregewitz | last post by:
I am uploading a zip file using an HttpWebRequest and a PUT operation to Sharepoint (2003) from a Windows Form application. When I upload the same file using the Sharepoint Portal Web UI itself,...
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: 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
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?
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...

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.