Srejon Khan
❔ 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!9 replies
Stack and Heap Memory [Answered]
I've been correcting some of my misconception about stack and heap memory allocation. So, this is my final verdict , I just want to make sure that I'm not holding any misconceptions. I had a misconception that all value types are stored on stack and all reference type are stored on heap, which I found out that partially wrong.
So, after some research, this is my final verdict -
"Short lived variables are considered to go on the stack/registers, where long lived variables are considered to go on the heap."
The variable of a reference type just hold the reference (address) of the instance of that reference type, and the instance of a reference type always stored in heap, right? And this variable of reference type can either stay in stack or heap depending on it's lifetime, right?
So, if value type is defined as local variable (including parameter), it will be stored on stack if not captured by closure. If value type is defined as a member of a reference type, then that value type is also going to be stored on the heap? Along with that reference type?
And, whatever variables Closure captures, will always goes to heap, right? As that is considered as long lived.
When we use ref keyword with a value type, it just passes the reference. It doesn't box the value, right?
When we use ref keyword with a value type, it just passes the reference. It doesn't box the value, right?
28 replies