0

While uploading the DeviceFarm S3 url for file uploading getting error code:ECONNRESET.

This is my code:

var AWS = require('aws-sdk');
var fs = require('fs'); 
var req = require('request');
var devicefarm = new AWS.DeviceFarm();
AWS.config.loadFromPath('C:/Users/Abin.mathew/AWSdata/config.json');
var apkPath= "D:/DTS/APKs/TPLegacyPlugin-googleplaystore-debug-rc_16.2.15.apk";
var stats = fs.statSync(apkPath);
var url= "https://prod-us-west-2-uploads.s3-us-west-2.amazonaws.com/arn%3Aaws%3Adevicefarm%3Aus-west-2%3A594587224081%3Aproject%3Ade07f584-7c64-4748-aebd-ec965ab107cf/uploads/arn%3Aaws%3Adevicefarm%3Aus-west-2%3A594587224081%3Aupload%3Ade07f584-7c64-4748-aebd-ec965ab107cf/5dd627eb-4eb2-4f2d-a300-0fde0720bde4/MyAppiumPythonUpload?AWSAccessKeyId";

fs.createReadStream(apkPath).pipe(req({
  method: 'PUT',
  url: url,
  headers: {
    'Content-Length': stats['size']
  }
}, function (err, res, body) { 
   console.log(body);
   console.log(res);
   console.log(err);
}));
Coder
  • 79
  • 8

1 Answers1

1

Your URL is incorrect. It represents the Appium test package but you are trying to upload an APK. Are you reusing a URL from a previous operation? Pre-signed URLs also expire after a period of time so they should not be reused.

To make this work,

  1. Call CreateUpload and get the pre-signed URL from the result.
  2. Post the correct file to the URL.

We have published a blog post that describes the procedure to follow. The code samples use the CLI but translating them to nodejs should be trivial.

Rohan Deshpande
  • 3,535
  • 1
  • 26
  • 31
  • Thanks for your response.But again i have generated a new URL against a new .apk file,but now its showing "Error: read ECONNRESET" – Coder Nov 02 '16 at 07:22
  • Is their a constrain for the size of the file, i guess its due to some timeOut error – Coder Nov 02 '16 at 07:24
  • File size limit is 4 GB. There are too many potential causes for a connection reset so I don't have a single solution to provide. You can try uploading your file from an EC2 instance running in us-west-2 to minimize network latency, since the AWS Device Farm service endpoint is hosted in us-west-2. – Rohan Deshpande Nov 08 '16 at 18:10
  • Now i am getting Signature Mismatch Error – Coder Nov 09 '16 at 11:10