0

I'm having a problem with timeouts on the third attempt to call a HttpWebRequest.GetRequestStream. This is for debug code to test an intermittent problem with a third party resource, so it is just making the same request over and over.

This problem does not manifest itself when using Fidder as a proxy, so this leads me to believe it has something to do with open connections in the connection pool (I remember reading somewhere that two attempts has something to do with the Http 1.1 spec).

A number of questions talks about closing the request and closing the response, but I have a using statement around both, so thought this would happen automatically when it goes out of scope. However I've also tried calling close and flush on both the request and response streams.

There's also questions that mention setting the ConnectionLeaseTimeout to 0. But that didn't work either.

I'm not sure what else to try, does anyone have any suggestions?

Community
  • 1
  • 1
Mr Shoubs
  • 14,629
  • 17
  • 68
  • 107
  • Are we allowed to know what the third party resource is? Even a rough idea might help. – Martin Brown Dec 10 '12 at 13:10
  • Just a URL that I pass post data too. I can't reveal what it is though due to confidentiality agreements. I think this is a standard problem and would be an issue with any repeated attempts. – Mr Shoubs Dec 10 '12 at 13:17
  • Have you any idea what web server they are running? Also do you have any access to their servers? Are there any firewalls involved? – Martin Brown Dec 10 '12 at 13:19
  • No, I asked about this. Also there is a 10 second gap between requests - I'm pretty sure the problem is in my code? – Mr Shoubs Dec 10 '12 at 16:03

2 Answers2

0

Have you tried setting the HttpWebRequest.HttpKeepAlive property to false before establising the connection?

Martin Brown
  • 24,692
  • 14
  • 77
  • 122
  • Part of the specification for the third party says I need to set KeepAlive to true. However, this still results in the same timeout problem. – Mr Shoubs Dec 10 '12 at 13:05
0

How much of a gap is there between each request? Is it possible that you are hitting some kind of firewall rule designed to keep out DoS attacks?

Martin Brown
  • 24,692
  • 14
  • 77
  • 122
  • No, I asked about this. Also there is a 10 second gap between requests - I'm pretty sure the problem is in my code? – Mr Shoubs Dec 10 '12 at 16:03