Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lots of socket hang up with S3 #701

Closed
sradu opened this issue Jun 1, 2018 · 18 comments
Closed

lots of socket hang up with S3 #701

sradu opened this issue Jun 1, 2018 · 18 comments
Assignees
Milestone

Comments

@sradu
Copy link

sradu commented Jun 1, 2018

We're running listObjectsV2 and fGetObject and receiving a lot of "Error: socket hang up" errors. The code is simple:

  const objectsStream = minioS3.listObjectsV2(bucketName, prefix, false);

  objectsStream.on('data', (obj) => {
    if (obj.name && obj.name.indexOf('_ckey') == -1) {
      filenames.push(obj.name);
    }
  });

  objectsStream.on('end', () => {
    callback(null, filenames);
  });

  objectsStream.on('error', (err) => {
    callback(err, null);
  });

It happens in large directories quite often, but is sometimes also triggered on smaller ones.

Any suggestions on how to handle this? listObjectsV2 is especially annoying since we can't retry chunks of the operation.

@kannappanr
Copy link
Contributor

@sradu Thanks for filing this issue. We will try to reproduce this issue and get back to you.

@Colhodm
Copy link
Contributor

Colhodm commented Jun 6, 2018

@sradu Approximately how many files are in your large directories on AWS?

@sradu
Copy link
Author

sradu commented Jun 6, 2018

It was around 150k. Tbh we switched to the raw AWS library and haven't had any problems since. While we haven't seen any errors with the raw version, doing it this way also allowed us to implement a retry mechanism.

@harshavardhana
Copy link
Member

The socket hang up usually happens when one hasn't drained the connection is the objectStream promise drained properly? @kannappanr @Colhodm

@deekoder
Copy link
Contributor

@kanagarajkm can you take a look at this issue?

@NickStefan
Copy link

NickStefan commented Aug 29, 2018

Hitting this. Would prefer not to have to move to raw aws library

@NickStefan
Copy link

Im getting this on fPutObject. I don't think that has to do with bucket size. So that taken with the original OP would mean:

  • fPutObject
  • fGetObject
  • listObjectsV2

ive tried both minio 3.0.0 and 7.0.0 . Works perfectly fine against Minio, but socket hangups against actual S3

@harshavardhana
Copy link
Member

We can see this now in all our mint tests

Mint Automation

Test Result
mint-worm.sh ✔️
mint-gateway-s3.sh more...
mint-gateway-azure.sh more...
mint-xl.sh more...
mint-gateway-nas.sh more...
mint-large-bucket.sh more...
mint-fs.sh more...
mint-dist-xl.sh more...

6380-53a3611/mint-gateway-nas.sh.log:

Running with
SERVER_ENDPOINT:      minikube:30093
ACCESS_KEY:           minio
SECRET_KEY:           ***REDACTED***
ENABLE_HTTPS:         0
SERVER_REGION:        us-east-1
MINT_DATA_DIR:        /mint/data
MINT_MODE:            full
ENABLE_VIRTUAL_STYLE: 0

To get logs, run 'docker cp bdb4cfb04135:/mint/log /tmp/mint-logs'
(1/13) Running awscli tests ... done in 49 seconds
(2/13) Running aws-sdk-go tests ... done in 0 seconds
(3/13) Running aws-sdk-java tests ... done in 2 seconds
(4/13) Running aws-sdk-php tests ... done in 41 seconds
(5/13) Running aws-sdk-ruby tests ... done in 1 seconds
(6/13) Running mc tests ... done in 16 seconds
(7/13) Running minio-dotnet tests ... done in 1 minutes and 21 seconds
(8/13) Running minio-go tests ... done in 20 seconds
(9/13) Running minio-java tests ... done in 1 minutes and 18 seconds
(10/13) Running minio-js tests ... FAILED in 5 minutes and 1 seconds
{
  "name": "minio-js",
  "function": "\"before all\" hook",
  "duration": 300030,
  "status": "FAIL",
  "error": "Error: socket hang up at createHangUpError (_http_client.js:258:15) at Socket.socketOnEnd (_http_client.js:350:23) at endReadableNT (_stream_readable.js:978:12) at _combinedTickCallback (internal/process/next_tick.js:80:11) at process._tickCallback (internal/process/next_tick.js:104:9)"
}

Executed 9 out of 13 tests successfully.

6380-53a3611/mint-xl.sh.log:

Running with
SERVER_ENDPOINT:      minikube:30984
ACCESS_KEY:           minio
SECRET_KEY:           ***REDACTED***
ENABLE_HTTPS:         0
SERVER_REGION:        us-east-1
MINT_DATA_DIR:        /mint/data
MINT_MODE:            full
ENABLE_VIRTUAL_STYLE: 0

To get logs, run 'docker cp f8c810735c50:/mint/log /tmp/mint-logs'
(1/13) Running awscli tests ... done in 46 seconds
(2/13) Running aws-sdk-go tests ... done in 0 seconds
(3/13) Running aws-sdk-java tests ... done in 1 seconds
(4/13) Running aws-sdk-php tests ... done in 41 seconds
(5/13) Running aws-sdk-ruby tests ... done in 1 seconds
(6/13) Running mc tests ... done in 13 seconds
(7/13) Running minio-dotnet tests ... done in 1 minutes and 15 seconds
(8/13) Running minio-go tests ... done in 25 seconds
(9/13) Running minio-java tests ... done in 1 minutes and 24 seconds
(10/13) Running minio-js tests ... FAILED in 5 minutes and 2 seconds
{
  "name": "minio-js",
  "function": "\"before all\" hook",
  "duration": 300015,
  "status": "FAIL",
  "error": "Error: socket hang up at createHangUpError (_http_client.js:258:15) at Socket.socketOnEnd (_http_client.js:350:23) at endReadableNT (_stream_readable.js:978:12) at _combinedTickCallback (internal/process/next_tick.js:80:11) at process._tickCallback (internal/process/next_tick.js:104:9)"
}

Executed 9 out of 13 tests successfully.

6380-53a3611/mint-fs.sh.log:

Running with
SERVER_ENDPOINT:      minikube:31932
ACCESS_KEY:           minio
SECRET_KEY:           ***REDACTED***
ENABLE_HTTPS:         0
SERVER_REGION:        us-east-1
MINT_DATA_DIR:        /mint/data
MINT_MODE:            full
ENABLE_VIRTUAL_STYLE: 0

To get logs, run 'docker cp f9f677a231de:/mint/log /tmp/mint-logs'
(1/13) Running awscli tests ... done in 47 seconds
(2/13) Running aws-sdk-go tests ... done in 0 seconds
(3/13) Running aws-sdk-java tests ... done in 2 seconds
(4/13) Running aws-sdk-php tests ... done in 41 seconds
(5/13) Running aws-sdk-ruby tests ... done in 2 seconds
(6/13) Running mc tests ... done in 15 seconds
(7/13) Running minio-dotnet tests ... done in 1 minutes and 20 seconds
(8/13) Running minio-go tests ... done in 22 seconds
(9/13) Running minio-java tests ... done in 1 minutes and 15 seconds
(10/13) Running minio-js tests ... FAILED in 5 minutes and 2 seconds
{
  "name": "minio-js",
  "function": "\"before all\" hook",
  "duration": 300022,
  "status": "FAIL",
  "error": "Error: socket hang up at createHangUpError (_http_client.js:258:15) at Socket.socketOnEnd (_http_client.js:350:23) at endReadableNT (_stream_readable.js:978:12) at _combinedTickCallback (internal/process/next_tick.js:80:11) at process._tickCallback (internal/process/next_tick.js:104:9)"
}

Executed 9 out of 13 tests successfully.

6380-53a3611/mint-large-bucket.sh.log:

Running with
SERVER_ENDPOINT:      minikube:31645
ACCESS_KEY:           minio
SECRET_KEY:           ***REDACTED***
ENABLE_HTTPS:         0
SERVER_REGION:        us-east-1
MINT_DATA_DIR:        /mint/data
MINT_MODE:            full
ENABLE_VIRTUAL_STYLE: 0

To get logs, run 'docker cp 348c4dc3c156:/mint/log /tmp/mint-logs'
(1/13) Running awscli tests ... done in 41 seconds
(2/13) Running aws-sdk-go tests ... done in 2 seconds
(3/13) Running aws-sdk-java tests ... done in 2 seconds
(4/13) Running aws-sdk-php tests ... done in 51 seconds
(5/13) Running aws-sdk-ruby tests ... done in 17 seconds
(6/13) Running mc tests ... done in 35 seconds
(7/13) Running minio-dotnet tests ... done in 4 minutes and 3 seconds
(8/13) Running minio-go tests ... done in 1 minutes and 33 seconds
(9/13) Running minio-java tests ... done in 3 minutes and 1 seconds
(10/13) Running minio-js tests ... FAILED in 5 minutes and 1 seconds
{
  "name": "minio-js",
  "function": "\"before all\" hook",
  "duration": 300014,
  "status": "FAIL",
  "error": "Error: socket hang up at createHangUpError (_http_client.js:258:15) at Socket.socketOnEnd (_http_client.js:350:23) at endReadableNT (_stream_readable.js:978:12) at _combinedTickCallback (internal/process/next_tick.js:80:11) at process._tickCallback (internal/process/next_tick.js:104:9)"
}

Executed 9 out of 13 tests successfully.

6380-53a3611/mint-dist-xl.sh.log:

Running with
SERVER_ENDPOINT:      minikube:31644
ACCESS_KEY:           minio
SECRET_KEY:           ***REDACTED***
ENABLE_HTTPS:         0
SERVER_REGION:        us-east-1
MINT_DATA_DIR:        /mint/data
MINT_MODE:            full
ENABLE_VIRTUAL_STYLE: 0

To get logs, run 'docker cp c4473c9bbd90:/mint/log /tmp/mint-logs'
(1/13) Running awscli tests ... done in 50 seconds
(2/13) Running aws-sdk-go tests ... done in 0 seconds
(3/13) Running aws-sdk-java tests ... done in 2 seconds
(4/13) Running aws-sdk-php tests ... done in 42 seconds
(5/13) Running aws-sdk-ruby tests ... done in 9 seconds
(6/13) Running mc tests ... done in 21 seconds
(7/13) Running minio-dotnet tests ... done in 3 minutes and 21 seconds
(8/13) Running minio-go tests ... done in 38 seconds
(9/13) Running minio-java tests ... done in 1 minutes and 40 seconds
(10/13) Running minio-js tests ... FAILED in 5 minutes and 0 seconds
{
  "name": "minio-js",
  "function": "\"before all\" hook",
  "duration": 300016,
  "status": "FAIL",
  "error": "Error: socket hang up at createHangUpError (_http_client.js:258:15) at Socket.socketOnEnd (_http_client.js:350:23) at endReadableNT (_stream_readable.js:978:12) at _combinedTickCallback (internal/process/next_tick.js:80:11) at process._tickCallback (internal/process/next_tick.js:104:9)"
}

Executed 9 out of 13 tests successfully.

6380-53a3611/mint-gateway-s3.sh.log:

Running with
SERVER_ENDPOINT:      minikube:30438
ACCESS_KEY:           AKIAJ3ORETMQUQXBBWGA
SECRET_KEY:           ***REDACTED***
ENABLE_HTTPS:         0
SERVER_REGION:        us-east-1
MINT_DATA_DIR:        /mint/data
MINT_MODE:            full
ENABLE_VIRTUAL_STYLE: 0

To get logs, run 'docker cp 076c0f5b4612:/mint/log /tmp/mint-logs'
(1/13) Running awscli tests ... done in 2 minutes and 57 seconds
(2/13) Running aws-sdk-go tests ... done in 3 seconds
(3/13) Running aws-sdk-java tests ... done in 5 seconds
(4/13) Running aws-sdk-php tests ... done in 1 minutes and 52 seconds
(5/13) Running aws-sdk-ruby tests ... done in 53 seconds
(6/13) Running mc tests ... done in 4 minutes and 58 seconds
(7/13) Running minio-dotnet tests ... done in 7 minutes and 40 seconds
(8/13) Running minio-go tests ... done in 9 minutes and 57 seconds
(9/13) Running minio-java tests ... done in 20 minutes and 25 seconds
(10/13) Running minio-js tests ... FAILED in 5 minutes and 0 seconds
{
  "name": "minio-js",
  "function": "\"before all\" hook",
  "duration": 300014,
  "status": "FAIL",
  "error": "Error: socket hang up at createHangUpError (_http_client.js:258:15) at Socket.socketOnEnd (_http_client.js:350:23) at endReadableNT (_stream_readable.js:978:12) at _combinedTickCallback (internal/process/next_tick.js:80:11) at process._tickCallback (internal/process/next_tick.js:104:9)"
}

Executed 9 out of 13 tests successfully.

6380-53a3611/mint-gateway-azure.sh.log:

Running with
SERVER_ENDPOINT:      minikube:31530
ACCESS_KEY:           minioazure
SECRET_KEY:           ***REDACTED***
ENABLE_HTTPS:         0
SERVER_REGION:        us-east-1
MINT_DATA_DIR:        /mint/data
MINT_MODE:            full
ENABLE_VIRTUAL_STYLE: 0

To get logs, run 'docker cp 31612b9829da:/mint/log /tmp/mint-logs'
(1/13) Running awscli tests ... done in 2 minutes and 49 seconds
(2/13) Running aws-sdk-go tests ... done in 3 seconds
(3/13) Running aws-sdk-java tests ... done in 7 seconds
(4/13) Running aws-sdk-php tests ... done in 8 minutes and 11 seconds
(5/13) Running aws-sdk-ruby tests ... done in 48 seconds
(6/13) Running mc tests ... done in 5 minutes and 59 seconds
(7/13) Running minio-dotnet tests ... done in 5 minutes and 53 seconds
(8/13) Running minio-go tests ... done in 9 minutes and 17 seconds
(9/13) Running minio-java tests ... done in 19 minutes and 22 seconds
(10/13) Running minio-js tests ... FAILED in 5 minutes and 1 seconds
{
  "name": "minio-js",
  "function": "\"before all\" hook",
  "duration": 300015,
  "status": "FAIL",
  "error": "Error: socket hang up at createHangUpError (_http_client.js:258:15) at Socket.socketOnEnd (_http_client.js:350:23) at endReadableNT (_stream_readable.js:978:12) at _combinedTickCallback (internal/process/next_tick.js:80:11) at process._tickCallback (internal/process/next_tick.js:104:9)"
}

Executed 9 out of 13 tests successfully.

@kanagarajkm
Copy link
Collaborator

minio/minio#6390 fixes the socket hang issue which is currently happening on the latest master.

@kanagarajkm
Copy link
Collaborator

kanagarajkm commented Aug 31, 2018

@NickStefan i have tested minio-js with AWS S3, i am not seeing any errors. Following is the code

var Minio = require("minio");

var minioClient = new Minio.Client({
  endPoint: "s3.amazonaws.com",
  accessKey: "ACCESS_KEY",
  secretKey: "SECRET_KEY"
});

const bucketName = BUCKET_NAME;
const filepath = FILE_PATH;

minioClient.fPutObject(bucketName, "sample3.jpg", filepath, (err, etag) => {
  console.log(err, etag);
  listObjects();
});

function listObjects() {
  const objectsStream = minioClient.listObjectsV2(bucketName, "", false);
  objectsStream.on("data", obj => {
    if (obj.name) {
      console.log(obj.name);
    }
  });

  objectsStream.on("end", () => {
    console.log("end");
  });

  objectsStream.on("error", err => {
    console.log(err);
  });
}

Can you provide the sample code if you are hitting the issue?

@NickStefan
Copy link

minioClient = new Minio.Client({
        endPoint: 's3.amazonaws.com',
        port: 80,
        useSSL: true,
        accessKey: S3_KEY,
        secretKey: S3_SECRET,
        region: S3_BUCKET_REGION,
    });

    const src = getPathFromFile(file);
    const metaData = {
        "Content-Type": file.mimetype,
        "ACL": 'public-read',
    };
    await minioClient.fPutObject(S3_UPLOADS_BUCKET, dest, src, metaData);

like the other guy i had to move on because this is for work. I ended up patching the minioClient object because i do like being able to use minio locally without s3:

const fPutObject = async (bucket, dest, src, metaData) => {
    const AWS = require('aws-sdk');
    const { promisify } = require('util');
    const { readFile } = require('./utils');

    AWS.config.update({
        region: S3_BUCKET_REGION,
        accessKeyId: S3_KEY,
        secretAccessKey: S3_SECRET,
    });

    const S3 = new AWS.S3({httpOptions: {timeout: 0}, params: {Bucket: bucket }});
    const data = await readFile(src);
    const params = {
        Key: dest,
        Body: data,
        ContentType: metaData['Content-Type'],
        ACL: metaData['ACL'],
    };
    const options = {partSize: 5 * 1024 * 1024, queueSize: 4};
    return await S3.upload(params, options).promise();
};

The raw AWS function works perfect.
Also im doin this within a docker container. node:8-slim

@kanagarajkm
Copy link
Collaborator

@NickStefan Can you remove port from the following code and try again

minioClient = new Minio.Client({
    endPoint: 's3.amazonaws.com',
    port: 80,
    useSSL: true,
    accessKey: S3_KEY,
    secretKey: S3_SECRET,
    region: S3_BUCKET_REGION,
});

@kanagarajkm
Copy link
Collaborator

@NickStefan did you get a chance to test this out?

@kanagarajkm
Copy link
Collaborator

@sradu can you provide the Minio.Client initialization code?

@NickStefan
Copy link

@kanagarajkm apologies, I have not yet, but will try and get to it today.

@kanagarajkm
Copy link
Collaborator

@NickStefan no problem, thank you.

@NickStefan
Copy link

@kaankabalak that did address the socket hangups

@kannappanr
Copy link
Contributor

@NickStefan Thanks for confirming that it works. Closing the issue based on your feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants