title: System.Net.WebException: Unable to read data from the transport connection: The connection was closed.
body: <p>Sometimes the following error occurs by downloading a (large) file:</p>
  
  <blockquote>
    <p>System.Net.WebException: An exception occurred during a WebClient request. ---> System.IO.IOException: Unable to read data from the transport connection: The connection was closed.
       at System.Net.ConnectStream.EndRead(IAsyncResult asyncResult)
       at System.Net.WebClient.DownloadBitsReadCallbackState(DownloadBitsState state, IAsyncResult result)
       --- End of inner exception stack trace ---</p>
  </blockquote>
  
  <p>For me that sounds like the server times out but I am not sure about that. I hope you guys can explain me that issue. And mabe offer a fix for that.</p>
  
  <p>The download logic looks like that:</p>
  
  <pre><code>            WebClient client = new WebClient();
              client.DownloadFileCompleted += (sender, e) =&gt;
              {
                  if (e.Error != null)
                  {
                      BridgeManager.logNow("DownloadingError:\n" + e.Error.ToString());
                  }
  
                  if (e.Cancelled)
                  {
                      BridgeManager.logNow("Game file download canceled!");
                  }
                  else
                  {
                      BridgeManager.logNow("Game files downloaded!");
                      success = true;
                      downloadFinished.Set();
                  }
              };
  
  
  
  
              client.DownloadFileAsync(downloadGameAddr, file);
  </code></pre>