ARTICLE AD BOX
I’m using the AWS S3 .NET SDK (Amazon.S3 + TransferUtility) to download files from an S3 bucket. Most file types download correctly (.txt, .zip, .webm, .ogv), but .mp4 and .mp3 always fail with this exception: System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host
However:
If I rename the .mp4 file to .ogv, the download works. Downloading the same .mp4 file via Cyberduck works. Java AWS SDK also downloads the same file without issues. So the object is valid and publicly downloadable — it just fails only in .NET for specific extensions. using System; using System.Threading.Tasks; using Amazon; using Amazon.Runtime; using Amazon.S3; using Amazon.S3.Transfer; class Program { static async Task Main(string[] args) { string accessKey = "YOUR_ACCESS_KEY"; string secretKey = "YOUR_SECRET_KEY"; string bucketName = "my-bucket-name"; string keyName = "folder/file.mp4"; string downloadPath = @"C:\Downloads\file.mp4"; var credentials = new BasicAWSCredentials(accessKey, secretKey); var config = new AmazonS3Config { RegionEndpoint = RegionEndpoint.APSouth1 }; using var s3Client = new AmazonS3Client(credentials, config); var transferUtility = new TransferUtility(s3Client); try { await transferUtility.DownloadAsync(downloadPath, bucketName, keyName); Console.WriteLine("Download complete!"); } catch (Exception ex) { Console.WriteLine($"Download failed: {ex.Message}"); } } }What I tried
Renaming .mp4 =.ogv = works Downloading same file using Cyberduck = works Downloading using AWS Java SDK → works Other file types (.txt, .zip, .ogv, .webm) = work Only .mp4 and .mp3 fail in .NET : might be more formats that dont workQuestion
Why does the AWS S3 .NET SDK fail to download .mp4 and .mp3 files with a “connection forcibly closed” error, and how can I fix it?
Is there a known issue related to MIME types, chunked transfer, HTTP/HTTPS settings, or S3 client configuration in .NET?
2
