为什么我想要开始新的 AWS Transcribe 作业时会超时?

Why do I get a timeout when I want to start a new AWS Transcribe job?

我正在尝试使用 Amazon Transcribe,但每当我开始新的 Transcribe 作业时,我都会收到以下[​​=26=]超时错误:

    Error Error: TimeoutError
    at ClientRequest.<anonymous> (/Users/mrx/Desktop/Entwicklung/Backend/node_modules/@aws-sdk/credential-provider-imds/dist/cjs/remoteProvider/httpRequest.js:17:20)
    at ClientRequest.emit (events.js:314:20)
    at Socket.emitRequestTimeout (_http_client.js:715:9)
    at Object.onceWrapper (events.js:420:28)
    at Socket.emit (events.js:326:22)
    at Socket._onTimeout (net.js:483:8)
    at listOnTimeout (internal/timers.js:554:17)
    at processTimers (internal/timers.js:497:7) {
  '$metadata': { attempts: 1, totalRetryDelay: 0 }
}

编辑:我有时也会收到以下 “无法连接到实例元数据服务” 错误:

Error ProviderError: Unable to connect to instance metadata service
    at ClientRequest.<anonymous> (/Users/mrx/Desktop/Entwicklung/Backend/node_modules/@aws-sdk/credential-provider-imds/dist/cjs/remoteProvider/httpRequest.js:14:34)
    at ClientRequest.emit (events.js:314:20)
    at Socket.socketErrorListener (_http_client.js:427:9)
    at Socket.emit (events.js:314:20)
    at emitErrorNT (internal/streams/destroy.js:92:8)
    at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
    at processTicksAndRejections (internal/process/task_queues.js:84:21) {
  tryNextLink: true,
  errno: 'EHOSTDOWN',
  code: 'EHOSTDOWN',
  syscall: 'connect',
  address: '149.124.129.254',
  port: 80,
  '$metadata': { attempts: 1, totalRetryDelay: 0 }
}

这就是我的 transcribe_create_job.js 文件的样子:

const StartTranscriptionJobCommand = require("@aws-sdk/client-transcribe")
const transcribeClient = require("./libs/transcribeClient.js")

const dotenv = require('dotenv')
const result = dotenv.config({path: __dirname + '/./../../../../.env'})
 
if (result.error) {
  throw result.error
}

// Set the parameters
const params = {
  TranscriptionJobName: "Transcription Test",
  LanguageCode: "en-US",
  MediaFormat: "webm", 
  Media: {
    MediaFileUri: "https://speech-recognition.s3.eu-central-1.amazonaws.com/djoqiipn.webm",
  },
};

const run = async () => {
  try {
    const data = await transcribeClient.send(
      new StartTranscriptionJobCommand(params)
    );
    console.log("Success - put", data);
    return data; // For unit tests.
  } catch (err) {
    console.log("Error", err);
  }
};
run()

这就是我的 transcribeClient.js 文件的样子:

const dotenv = require('dotenv')
const result = dotenv.config({path: __dirname + '/../.env'})
 
if (result.error) {
  throw result.error
}

const { TranscribeClient } = require("@aws-sdk/client-transcribe");
const REGION = result.parsed.AWS_REGION
const transcribeClient = new TranscribeClient({ region: REGION });
module.exports = transcribeClient

我从官方文档中复制了代码,但我无法弄清楚为什么会出现此错误。我也没有在网上找到任何关于这个错误的解释,所以我希望其他人知道我为什么会收到这个错误。

提前感谢您的帮助! 莫里斯

请使用此方法

var params = {
  Media: { /* required */
    MediaFileUri: 'STRING_VALUE'
  },
  TranscriptionJobName: 'STRING_VALUE', /* required */

  MediaFormat: webm,
  
  
};
TranscribeClient.startTranscriptionJob(params, function(err, data) {
  if (err) console.log(err, err.stack); // an error occurred
  else     console.log(data);           // successful response
});

通过执行我所做的 以及向客户端函数添加 AWS_REGION、AWS_ACCESS_KEY 和 AWS_SECRET_KEY 解决了我的问题。

const { TranscribeClient } = require("@aws-sdk/client-transcribe");
const transcribeClient = new TranscribeClient({ AWS_REGION, AWS_ACCESS_KEY, AWS_SECRET_KEY});
module.exports = { transcribeClient };