# [.net] HttpWebRequest Errors and Problems

This topic is 4523 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

##### Share on other sites
Kag,

I can probably offer you some help. Can you post a bit of code or send me a PM so I can take a look at how you're setting up the HttpWebRequest object. It would also be nice to see how you're submitting the query, ie. asynchronously or synchronously.

Cheers!

##### Share on other sites
It may be that hosts have a limit on how often you can access them in a certain timeframe, to protect themselves from DOS attacks. In real life you'd never need more than say 5 hits from the same client in a second.

##### Share on other sites
It may be that you're behind a NAT router and it's not allowing more than a certain amount of dynamic NAT sessions from your host at once.

That seems quite likely.

Mark

##### Share on other sites

Here is the the code that I use to Send the Request
            HttpWebRequest WebReq = null;            try            {                WebReq = (HttpWebRequest)WebRequest.Create(LinkToCheck.Address.Replace("&", "&"));                WebReq.AllowAutoRedirect = false;                WebReq.Timeout = 15000;            }            catch            {                //blah blah failed for some reason            }            HttpWebResponse WebResp = null;            try            {                if (WebReq != null)                    WebResp = (HttpWebResponse)WebReq.GetResponse();            }            catch (Exception e)            {                 //Get the WebException and find out what kind of error we got            }

And that's basically all I do with the WebRequest end.

markr:
I had this same problem when it was single threaded, and just ran one at a time (the process just took 10 times longer)...could the problem you mentioned still be a problem with a single threaded app?

##### Share on other sites
Quote:
 Original post by kag1markr:I had this same problem when it was single threaded, and just ran one at a time (the process just took 10 times longer)...could the problem you mentioned still be a problem with a single threaded app?

Well, possibly.

Personally I'd get out your favourite network analyser and have a look at the frames on the wire to see what's happening to those timed out connections.

NAT routers doing "dynamic NAT", have only finite space in their nat tables. They therefore, sometimes limit the number of entries per host (so that one host making an excessive number of connections can't deny service to others).

It's possible that the web client isn't properly closing the connections (Microsoft web clients have a history of this), or the router holds the NAT table entry open for a little while after the connection is closed (to allow the host to send negative replies to any long-lost frames that come back etc, to be polite).

It's entirely possible also that the target host has a rate-limiter.

Also your proxy server (or transparent proxy) could be rate limiting something.

Check whether your ISP uses a transparent proxy (Many do).

If you still get the problem with a local network web server in the absence of either a transparent proxy or NAT router, I'd be fairly surprised.

Mark

1. 1
2. 2
3. 3
Rutin
19
4. 4
5. 5
JoeJ
12

• 14
• 22
• 9
• 31
• 17
• ### Forum Statistics

• Total Topics
632617
• Total Posts
3007470
• ### Who's Online (See full list)

There are no registered users currently online

×