Error: Cellular Hanging Code: "ECONNRESET" in Google Cloud Storage

We keep getting ECONNRESET error when trying to upload images to Google Cloud Storage.

var storage = require('gcloud').storage({
    projectId: projectNumber,
    credentials: credentials
});

//...

var file = Storage.bucket('myBucket').file('test.png');
fs.createReadStream('/path/to/image.png').pipe(file.createWriteStream({
    metadata: {
        contentType: 'image/png',
        cacheControl: 'public, max-age=2592000'
    }
}).on('complete', function () {
  //
}).on('error', function (err) {
  // err = Error: socket hang up || Request Timeout after 30000ms
});

      

+3


source to share


1 answer


I don't know why no one answered this question. I have the same error and resolve it by setting resumable and checking to false :

var gcsStream = Storage.bucket('myBucket').file('test.png').createWriteStream({
      resumable: false,
      validation: false,
      metadata: {
        contentType: 'image/png'
      }
    });
fs.createReadStream('/path/to/image.png').pipe(gcsStream);

      



Without two settings, I get Socket crash error whenever I load 20 ~ 30 images at the same time.

+1


source







All Articles