David Brown

David Brown

  • NA
  • 34
  • 479

HttpClient downloads files and writes them asynchronously using stream

Aug 7 2023 8:31 AM

As the title says, when downloading a file and reading the stream in a loop and writing to disk, sometimes the download gets stuck in a weak network environment (disk file size does not change for a long time), and the application does not appear abnormal. What is the reason? How to avoid and solve it?

By browsing the website, the known solution is to detect whether the size of the disk file changes within a period of time, and re-initiate the download request if the file size does not change. Is there any other solution?

Thanks to everyone who provided advice!


Answers (2)