amazon-web-servicesaws-sdk-jsaws-sdk-nodejsamazon-transcribe

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


I'm trying to use Amazon Transcribe, but whenever I start a new Transcribe job I receive the following timeout error:

    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 }
}

EDIT: I also sometimes get the following "Unable to connect to instance metadata service" error:

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 }
}

That's what my transcribe_create_job.js file looks like:

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()

That's what my transcribeClient.js file looks like:

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

I copied the code from the official documentation, but I can't figure out why I get this error. I don't find any explanation to this error online as well, so I hope somebody else knows why I get the error.

Thank you for your help in advance! Maurice


Solution

  • Solved my problem by doing what I did here as well as adding AWS_REGION, AWS_ACCESS_KEY and AWS_SECRET_KEY to the client function.

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