minio / minio-js

MinIO Client SDK for Javascript
https://docs.min.io/docs/javascript-client-quickstart-guide.html
Apache License 2.0
920 stars 271 forks source link

Error: connect ETIMEDOUT #1274

Closed xdxddxd closed 4 months ago

xdxddxd commented 4 months ago

Code

// file: src/services/upload/index.ts
import * as Minio from 'minio';

const minioClient = new Minio.Client({
    endPoint: process.env.MINIO_ENDPOINT || 'localhost',
    port: 9000,
    useSSL: false,
    accessKey: process.env.MINIO_ACCESSKEY || '',
    secretKey: process.env.MINIO_SECRETKEY || '',
});

export async function generatePresignedUrl(objectName: string): Promise<string> {
    console.log('➡ Generating presigned URL for object:', objectName);
    const url = await minioClient.presignedPutObject('raffle', objectName);
    return url;
}

Response

image

Console

 ⨯ Error: connect ETIMEDOUT IPADD:9000
    at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1595:16)
digest: "522196566"
prakashsvmx commented 4 months ago

is there an issue @xdxddxd ?

xdxddxd commented 4 months ago

is there an issue @xdxddxd ?

Yes, I'm trying to get a pre-signed url but it's giving me this problem, I'm using Minio's npm package, I configured it the way it's described in the documentation and it keeps giving me this error, is there another way to connect with Minio?

prakashsvmx commented 4 months ago

i am running similar one locally . It works as expected. So double check credentials, endpoint , port and network connectivity.

var Minio = require('minio')

var minioClient = new Minio.Client({
    endPoint: 'localhost',
    port: 22000,
    useSSL: false,
    accessKey: 'minio',
    secretKey: 'minio123'
});

async function generatePresignedUrl(bucketName, objectName) {
    console.log('➡ Generating presigned URL for object:', objectName);
    const url = await minioClient.presignedPutObject(bucketName, objectName);

    console.log(`Presigned URL for ${bucketName} ${objectName} is:${url}`)
    return url;
}

 generatePresignedUrl('test-bucket','1.txt')

Result

 ➜ node api-tests/presinged-url.js
➡ Generating presigned URL for object: 1.txt
Presigned URL for test-bucket 1.txt is:http://localhost:22000/test-bucket/1.txt?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=minio%2F20240404%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20240404T123804Z&X-Amz-Expires=604800&X-Amz-SignedHeaders=host&X-Amz-Signature=266a4145172ba18a179807ddf31f986d73c356a75247a15c2dbf6ed14fd2c40f