I am developing a software in WPF to upload files on amazon cloud. I am able to successfully upload file using httpweb reuqest object. My problem is that when i pause the upload (i have created a pause button) it should be stop uploading at that time, but when i resume the upload, it display the following exception and the upload get suspended.
Unable to write data to the transport connection: An existing connection was forcibly closed by the remote host.
My code is as follows:-
Amazon.S3.AmazonS3 s3Client = new Amazon.S3.AmazonS3Client(AccessKey, SecretKey);
Amazon.S3.Model.GetPreSignedUrlRequest request = new Amazon.S3.Model.GetPreSignedUrlRequest();
request.Verb = Amazon.S3.Model.HttpVerb.PUT;
string url = null;
url = s3Client.GetPreSignedURL(request);
HttpWebRequest httpRequest = WebRequest.Create(url) as HttpWebRequest;
httpRequest.Method = "PUT";
httpRequest.Timeout = -1;
httpRequest.ReadWriteTimeout = -1;
httpRequest.KeepAlive = true;
httpRequest.ProtocolVersion = HttpVersion.Version11;
httpRequest.ServicePoint.ConnectionLimit = 10;
httpRequest.AllowWriteStreamBuffering = false;
httpRequest.ContentLength = FileSize;
Stream writeStream = httpRequest.GetRequestStream();
currentPackageSize = stream.Read(buffer, 0, buffer.Length);
if (currentPackageSize > 0)
writeStream.Write(buffer, 0, currentPackageSize);
I need the solution as soon as possible. Thanks in Advance.