Turistforeningen / node-s3-uploader

Flexible and efficient resize, rename, and upload images to Amazon S3 disk storage. Uses the official AWS Node SDK for transfer, and ImageMagick for image processing. Support for multiple image versions targets.
https://www.npmjs.com/package/s3-uploader
MIT License
241 stars 54 forks source link

TimeoutError: Connection timed out after 10000ms #121

Open meghjoshi opened 7 years ago

meghjoshi commented 7 years ago

TimeoutError: Connection timed out after 10000ms

The image is uploaded on s3 with all their sub variations but after uploading i am getting error for Connection timeout

Your environment

var client = new s3Upload(awsbucket, {
    aws: {
        path: 'images/',
        region: 'us-west-2',
        acl: awsACL,
        accessKeyId: awsKeyId,
        secretAccessKey: awsKey,
    },

    cleanup: {
        versions: true,
        original: false
    },

    original: {
        awsImageAcl: 'public-read'
    },

    versions: [{
        maxHeight: 1040,
        maxWidth: 1040,
        format: 'jpg',
        quality: 80,
        suffix: '-large',
        folderPath: 'large/'
    }, {
        maxWidth: 780,
        aspect: '3:2!h',
        suffix: '-medium',
        folderPath: 'medium/'
    }, {
        maxWidth: 320,
        aspect: '16:9!h',
        suffix: '-small',
        folderPath: 'small/'
    }, {
        maxHeight: 250,
        maxWidth: 250,
        aspect: '1:1',
        suffix: '-thumb',
        folderPath: 'thumb/'
    }]
});
var fileCounter = 0;
var filepath = req.file.path;
var filename = req.file.filename;
client.upload(filepath, {}, function (err, versions, meta) {
    if (err) {
        throw err;
    }

    versions.forEach(function (image) {
        fileCounter++;
        console.log(image);
        console.log('versions.length',versions.length);
        console.log('fileCounter',fileCounter);
        //console.log(image.width, image.height, image.url);
        if (fs.existsSync(filepath)) {
            fs.unlinkSync(filepath);
        }
        if (versions.length === fileCounter) {
            var im =image.key.split('/');
            return res.json({success: true, filename: im[im.length - 1]});
        }
        // 1024 760 https://my-bucket.s3.amazonaws.com/path/110ec58a-a0f2-4ac4-8393-c866d813b8d1.jpg
    });
});
and getting error like belwo image
http://i.prntscr.com/62fad87356564e7f9bd3eb3bac93294a.png
javiercf commented 7 years ago

any update on this?

alfiepoleon commented 7 years ago

From this aws sdk documentation Try this

  aws: {
    path: '...',
    region: '...',
    acl: '...',
    httpOptions: { timeout: 120000 }, // Play with values here (milliseconds)
    accessKeyId: '...',
    secretAccessKey: '...',
  }
iggyZiggy commented 7 years ago

tried the last solution, error just changed to:

RequestTimeout: Your socket connection to the server was not read from or written to within the timeout period. Idle connections will be closed.
iggyZiggy commented 7 years ago

for anyone else who gets stuck on this one, double check your aws.region if it's the right one

abhishekp1996 commented 6 years ago

By default the region is us-east-1. If you have server in some other location, add the region property in aws key in client object. I solved it this way. Hope this helps. :)