Go Back   Velocity Reviews > Newsgroups > ASP Net
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read


Reply

ASP Net - HttpWebRequest The operation has timed-out

 
Thread Tools Search this Thread
Old 10-26-2005, 08:38 PM   #1
=?Utf-8?B?TWFuc28=?=
 
Posts: n/a
Default 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

  Reply With Quote
Old 10-26-2005, 09:34 PM   #2
=?Utf-8?B?TWFuc28=?=
 
Posts: n/a
Default RE: HttpWebRequest The operation has timed-out

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...p?f rame=true

Solution found thanks to:

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

Regards,
Manso
  Reply With Quote
Old 07-25-2008, 07:02 AM   #3
Nyoti
Junior Member
 
Join Date: Jul 2008
Posts: 1
Smile

Thanks a lot Monso for the solution.
I just would like to know more details about keepalive property of http request.
Nyoti is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
synthesizable divide operation in VHDL varshini Hardware 0 12-02-2008 05:55 AM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47