Skip to content

AWS HealthScribe Streaming error (AWS SDK JS v3): initiating stream results in http 500, seems to be sent over wss instead of h2

0

I'm attempting to start a MedicalScribe stream from the browser using the StartMedicalScribeStreamCommand, sent using the ask's TranscribeStreamingClient. I am consistently getting a 500 in response and can not find details about why.

  • verified permissions (including S3 put and assume role)
  • verified can initiate other types of streams like StartStreamTranscriptionCommand over wss and same audio source / processing

Logged error is not very helpful:

Error
    at asSdkError (http://localhost:8910/@fs/.../node_modules/.vite/deps/@aws-sdk_client-transcribe-streaming.js?v=a772c66c:6178:26)
    at http://localhost:8910/@fs/.../node_modules/.vite/deps/@aws-sdk_client-transcribe-streaming.js?v=a772c66c:7317:21
    at async http://localhost:8910/@fs/.../node_modules/.vite/deps/@aws-sdk_client-transcribe-streaming.js?v=a772c66c:8105:20
    at async http://localhost:8910/@fs/.../node_modules/.vite/deps/@aws-sdk_client-transcribe-streaming.js?v=a772c66c:4172:20
    at async http://localhost:8910/@fs/.../node_modules/.vite/deps/@aws-sdk_client-transcribe-streaming.js?v=a772c66c:1074:22

What I can tell is that the browser is attempting to connect to the streaming service over wss which seems to be unsupported for medical scribe streaming. Documentation states HTTP/2 only.

Is the reason for 500 because the browser is trying to establish a websocket instead of an HTTP/2 stream? Is there anything I can do to work around this issue?

Sample code:

Event stream

      createStream: async function* (): AsyncGenerator<
        MedicalScribeInputStream,
        void,
        unknown
      > {
        yield { ConfigurationEvent: configurationEvent }

        while (controller.isStreaming) {
          if (controller.audioQueue.length > 0) {
            const chunk = controller.audioQueue.shift()
            const audioEvent: MedicalScribeAudioEvent = {
              AudioChunk: new Uint8Array(chunk),
            }
            yield { AudioEvent: audioEvent }
          } else {
            await new Promise<void>((resolve) => {
              controller.resolveDataPromise = resolve
            })
            if (!controller.isStreaming) break
          }
        }

        const endSessionEvent: MedicalScribeSessionControlEvent = {
          Type: 'END_OF_SESSION',
        }
        yield { SessionControlEvent: endSessionEvent }
      },
1 Answer
0

The issue you're experiencing with AWS HealthScribe Streaming is likely due to the browser attempting to establish a WebSocket connection (wss) instead of the required HTTP/2 stream. This is indeed unsupported for medical scribe streaming, as the documentation specifies that HealthScribe only supports HTTP/2.

The 500 error you're receiving is probably a result of this mismatch in protocols. Unfortunately, there isn't a straightforward way to use HTTP/2 directly from a browser environment, as browsers typically don't provide direct access to HTTP/2 APIs.

To work around this issue, you have a few options:

  1. Server-side proxy: Implement a server-side application that can handle the HTTP/2 communication with AWS HealthScribe. Your browser-based application would then communicate with this proxy server using WebSockets or another browser-friendly protocol.

  2. WebAssembly: Explore using WebAssembly to compile a language with HTTP/2 support (like Rust or C++) to run in the browser. This is a more complex solution but could potentially allow direct HTTP/2 communication from the browser.

  3. Electron or similar: If your application can be packaged as a desktop application using something like Electron, you could use Node.js on the backend, which does support HTTP/2.

  4. AWS Amplify: Consider using AWS Amplify, which might provide a more browser-friendly way to interact with AWS services, including potentially HealthScribe.

Given the constraints of browser environments and the specific requirements of AWS HealthScribe, the server-side proxy approach is likely the most practical solution for most use cases. This would allow you to maintain your browser-based frontend while ensuring proper communication with the HealthScribe service.
Sources
AWS HealthScribe - Amazon Transcribe
MedicalScribeResultStream - Amazon Transcribe

answered 7 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.