I'm using Amazon S3 as photo storage and I'm constantly getting this error:
RequestTimeout: Your socket connection to the server was not read from or written to within the timeout period. Idle connections will be closed.
Here's the code:
function(source, name, callback) {
var awsUtils = this;
fs.stat(source, function(err, file_info) {
console.log(file_info);
var bodyStream = fs.createReadStream(source);
var params = {
Key : name,
ContentLength : file_info.size,
Body : bodyStream
};
awsUtils.s3bucket.putObject(params, function (err, data) {
if(err) {
console.error('AWSDriverUtils-unable to upload: ' + err);
callback(false);
} else {
console.log('AWSDriverUtils-upload success:', data);
callback(true);
}
});
});
}
The upload image file is small, about 44.0 KB only. While researching, I have found someone saying:
Amazon S3 will send that error response after 20 seconds of inactivity. The error indicates that Amazon S3 was attempting to read the request body, but no new data arrived over a period of 20 seconds.
What should I do to fix this, maybe a flush()
function?
I have also tried to comment out ContentLength in params.