3

I'm using HttpClient to download big files. To deal with slow connections, I have increased the Timeout property to 1 hour.

But, then, in case the connection is stalled (0 Kb/s for a reasonable time), I would like the connection to be forced to time out, because it's obviously an indication that something isn't going OK.

How do we deal with this situation?

SuperJMN
  • 13,110
  • 16
  • 86
  • 185
  • 1 hour timeout doesn't really make sense, its better to catch timeout exception (let timeout to be just a few seconds) and then try to reconnect if necessary. obviously, you should continue the download instead of downloading from scratch (im not familiar with this API) – M.kazem Akhgary Mar 10 '19 at 20:23

1 Answers1

0

We can call this as Slow HTTP Attacks (a kind of Denial of Service Attacks). In IIS 7 you can tune configurations below for protecting your services:

  • Limit request attributes is through the element, specifically the maxAllowedContentLength, maxQueryString, and maxUrl attributes.
  • Set to configure the type and size of header your web server will accept.
  • Tune the connectionTimeout, headerWaitTimeout, and minBytesPerSecond attributes of the and elements to minimize the impact of slow HTTP attacks.

For further information Check [1] [2] [3]

Derviş Kayımbaşıoğlu
  • 28,492
  • 4
  • 50
  • 72
  • Thanks for the anser, but I'm not on the server side, but on the client side. I would like to deal with stalled file transfers. – SuperJMN Mar 10 '19 at 21:40