❔ HttpClient - Error while copying content to a stream - AWS S3

Hello, I've been trying to upload file to AWS S3's presigned URL using POST method. All the presigned URL is coming from a third-party service and I can upload files without any problem from console application. The problem arises when error/exception happens on the AWS side. For example, if I'm trying to upload a file larger than the size limit that is defined for that presigned URL, the response gives an error in XML format describing the problem. In such case, from console side, my request can't complete to read the error messages. Rather, it throws Error while copying content to a stream. Excepted outcome is to read the response from console. Here is the code - https://gist.github.com/SrejonKhan/3259dbc64d07cb07fb3e5e33f739e891 ---Exception--- Message: Error while copying content to a stream. Stack Trace: https://elmah.io/tools/stack-trace-formatter/91b95889b9a140d39951bfd9158afc0c/ ---Inner Exception--- Message: Unable to write data to the transport connection: An existing connection was forcibly closed by the remote host. Stack Trace: https://elmah.io/tools/stack-trace-formatter/cfa9beae842a4981a9ce442e3acc873d/ ---Inner Exception--- Message: An existing connection was forcibly closed by the remote host. Workaround: If I try in HTTP/1.0 rather that HTTP/1.1, it works even in server side exception. But, it's terribly slow!
4 Replies
Cracker
Cracker2y ago
I can't point the problem here, if upload fails on AWS side, it returns http 5** with describing XML/HTML/JSON data If AWS server is not available then s3client.PostAsync might throw exception before your try catch block in that case you might want to call s3client.PostAsync inside try catch as well and handle that case another thing HttpClient is hard to manage
Srejon Khan
Srejon KhanOP2y ago
but I can't get the XML data, because it throws exception before my try catch. tried that too, same error.
Srejon Khan
Srejon KhanOP2y ago
Stack Overflow
How to get the HTTP response when the request stream was closed dur...
TL;DR version When a transfer error occurs while writing to the request stream, I can't access the response, even though the server sends it. Full version I have a .NET application that uploads ...
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server