Skip to content

Client-transcribe-streaming - Websocket is closing. #2428

@saravanakumargs

Description

@saravanakumargs

Describe the bug

While calling the StartMedicalStreamTranscriptionCommand, getting the error as websocket-handler.ts:101 WebSocket is already in CLOSING or CLOSED state

Your environment

Local system Testing.

SDK version number

@aws-sdk/client-transcribe-streaming@3.16.0

Is the issue in the browser/Node.js/ReactNative?

Browser/Node.js/ReactNative
Browser - Node Js React App.

Details of the browser/Node.js/ReactNative version

Paste output of npx envinfo --browsers or node -v or react-native -v

Steps to reproduce

Please share code or minimal repo, and steps to reproduce the behavior.

var params = {
  LanguageCode: "en-US",
  MediaSampleRateHertz: 16000,
  MediaEncoding: "pcm",
  AudioStream: null,
  Specialty: Specialty.CARDIOLOGY,
  Type: Type.CONVERSATION,
};

const client = new TranscribeStreamingClient({
  region: "us-east-2",
  credentials: {
    accessKeyId: REACT_APP_AWS_ACCESS_KEY,
    secretAccessKey: REACT_APP_AWS_SECRET_KEY,
  },
  maxAttempts: 5,
});

async function* audioStream() {
  console.log("inside audiostream");
  for await (const chunk of microphoneStream) {
    yield {
      AudioEvent: {
        AudioChunk: chunk,
      },
    };
  }
}

async function handleClick() {
  console.log("transcrit");
  console.log(currentStream);
  console.log(process.env);
  console.log(REACT_APP_AWS_ACCESS_KEY);
  console.log(REACT_APP_AWS_SECRET_KEY);
  console.log(REACT_APP_MY_ENV);
  if (microphoneStream === null) {
    microphoneStream = new MicrophoneStream();
  }
  microphoneStream.setStream(currentStream);
  console.log(microphoneStream);

  var transcribeparams = params;
  transcribeparams.AudioStream = audioStream();

  console.log(transcribeparams);
  command = new StartMedicalStreamTranscriptionCommand(params);
  console.log(command);
  try {
    const data = await client.send(command);
    console.log(data);
  } catch (error) {
    console.log("Inside error");
    console.log(error);
  } finally {
    console.log("finally");
  }
}    

Observed behavior

Websocket is in closed state. Even though I get 200 status code from the send command.

{$metadata: {…}, ContentIdentificationType: undefined, EnableChannelIdentification: undefined, LanguageCode: "en-US", MediaEncoding: "pcm", …}
$metadata:
attempts: 1
cfId: undefined
extendedRequestId: undefined
httpStatusCode: 200
requestId: undefined
totalRetryDelay: 0
__proto__: Object
ContentIdentificationType: undefined
EnableChannelIdentification: undefined
LanguageCode: "en-US"
MediaEncoding: "pcm"
MediaSampleRateHertz: 16000
NumberOfChannels: undefined
RequestId: undefined
SessionId: "3ffd0fcc-e99d-4f80-a8c9-30ada953d725"
ShowSpeakerLabel: undefined
Specialty: "CARDIOLOGY"
TranscriptResultStream:
Symbol(Symbol.asyncIterator): ƒ ()
__proto__: Object
Type: "CONVERSATION"
VocabularyName: undefined
__proto__: Object

Expected behavior

The transcripted output should come.

Metadata

Metadata

Assignees

Labels

bugThis issue is a bug.closed-for-stalenessp2This is a standard priority issueworkaround-availableThis issue has a work around available.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions