|
-
Aug 7th, 2013, 08:00 AM
#1
Thread Starter
Junior Member
[RESOLVED] HTTP Web Request multi-threading time out
Hello,
I have a multithreaded application that communicates with a web service by HTTP GETs.
when the program began to experience moderate load, it began to throw "The Operation Has Timed Out" errors on the function that is submitting HTTP Web Requests and retrieving the Web Response.
Another developer suggested this MSDN article: http://msdn.microsoft.com/en-us/library/fb6y0fyc.aspx
He was thinking it might be related, but it looks like something you configure in a web application via its web.config .
Also, here is the piece of my code that times out:
Code:
AwsWebRequest = System.Net.HttpWebRequest.Create("Example.com?exampleParam=example")
AwsWebRequest.Timeout = 10000 'TODO: timeout added for testing - should be able to remove when finished - 2013-08-01
AwsWebResponse = AwsWebRequest.GetResponse
AwsStreamReader = New System.IO.StreamReader(AwsWebResponse.GetResponseStream)
'Result parsing needs work. results will simply be to acknowledge successful request. final results will be posted back later.
AwsResult = AwsStreamReader.ReadToEnd
AwsWebResponse.Close()
My question is, am I missing something? Or is this related to a default connection limit? If so, can it be changed?
Thanks in advance!
-
Aug 7th, 2013, 09:30 AM
#2
Re: HTTP Web Request multi-threading time out
How many threads do you have active at any single moment??
-
Aug 7th, 2013, 10:19 AM
#3
Thread Starter
Junior Member
Re: HTTP Web Request multi-threading time out
20, as there are other things going on processing 15k records in one shot, individually, in varying ways.
It seems I may have figured it out with continued research and testing. It appears microsoft imposes a default network connection limit when contacting the same network host concurrently.
I had to set System.Net.ServicePointManager.DefaultConnectionLimit - Found it in this MSDN link: http://msdn.microsoft.com/en-us/libr...vs.100%29.aspx
It may default to 2 or 10 depending on the implementation of asp.net or not. I set it to something ridiculously high for testing and then ran my app at more than 2 times the pace and it experienced no time outs.
For the information of others: I set the property on the load event for the main form: System.Net.ServicePointManager.DefaultConnectionLimit=1000
Last edited by dontstealmyfish; Aug 7th, 2013 at 10:25 AM.
Reason: added general fix line for other users
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|