You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用aws-sdk连接OVH对象存储遇TimeoutError: socket hang up求助

调试OVH Object Storage连接问题的解决方案

从错误信息里能看到hostname: 's3.sbg.amazonaws.com',说明代码实际请求的是AWS默认Endpoint而非OVH存储地址,这是核心问题,以下是具体修复步骤:

1. 修正Endpoint参数拼写错误

AWS SDK的参数名是**endpoint**(小写字母p),你代码里写的是endPoint(大写P),导致该配置未被识别,SDK自动使用AWS默认地址。修改后:

const s3 = new AWS.S3({
  accessKeyId: '930*****************************',
  secretAccessKey: 'b7c****************************',
  endpoint: 'https://storage.sbg.cloud.ovh.net', // 修正参数名
  region: 'SBG',
});

2. 添加OVH存储必需的配置项

OVH Object Storage需要强制路径风格访问和指定签名版本v4,补充这两个配置:

const s3 = new AWS.S3({
  accessKeyId: '930*****************************',
  secretAccessKey: 'b7c****************************',
  endpoint: 'https://storage.sbg.cloud.ovh.net',
  region: 'SBG',
  s3ForcePathStyle: true, // OVH要求路径风格访问
  signatureVersion: 'v4', // 指定签名版本
});

3. 修复回调函数的错误处理

你的listBuckets回调只接收了data参数,未处理错误,导致错误对象被当成data打印。正确的回调需包含错误参数:

s3.listBuckets((err, data) => {
  if (err) {
    console.error('获取存储桶失败:', err);
    return;
  }
  console.log('存储桶列表:', data.Buckets);
});

额外检查项

  • 确认Access Key和Secret Key拥有ListBuckets权限
  • 检查网络环境是否能正常访问https://storage.sbg.cloud.ovh.net(可通过curl https://storage.sbg.cloud.ovh.net测试)

内容的提问来源于stack exchange,提问作者Meddah Abdallah

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.12 05:35:50