awslabs / amazon-transcribe-streaming-sdk

The Amazon Transcribe Streaming SDK is an async Python SDK for converting audio into text via Amazon Transcribe.
Apache License 2.0
142 stars 37 forks source link

RuntimeError: 1033 (AWS_IO_TLS_CTX_ERROR): Failed to create tls context #6

Closed anshitmt closed 3 years ago

anshitmt commented 4 years ago

When I make a call to start_stream_transcription method, I get the following error:

File "/app/src/core/aws_speech_recognizer.py", line 243, in send_data_to_asr
    media_encoding="pcm",
File "/usr/local/lib/python3.7/site-packages/amazon_transcribe/client.py", line 94, in start_stream_transcription
    session = AwsCrtHttpSessionManager(self._eventloop)
File "/usr/local/lib/python3.7/site-packages/amazon_transcribe/httpsession.py", line 118, in __init__
    self._tls_ctx = io.ClientTlsContext(io.TlsContextOptions())
File "/usr/local/lib/python3.7/site-packages/awscrt/io.py", line 420, in __init__
    options.verify_peer
RuntimeError: 1033 (AWS_IO_TLS_CTX_ERROR): Failed to create tls context

I am using my access-key and secret-key to run this inside a Docker with ubuntu:16.04 image. Having said that, I was able to run the same code perfectly on my mac.

Not sure if the issue is related to this library. I would appreciate your quick check.

nateprewitt commented 3 years ago

Hi @anshitmt, thanks for bringing this to our attention! If I had to guess at first glance, this is likely an openssl versioning issue, or system library used for encryption that's not available on the 16.04 docker image. The stacktrace here is actually part of our dependency, awscrt, that we'll need to work with to get some more info. Once we've got a clearer idea of what's failing, we'll update this ticket with some additional guidance.

nateprewitt commented 3 years ago

Hi again @anshitmt, We did some diving but are actually unable to reproduce this issue. I've included a simple Dockerfile we used to get Ubuntu 16.04 boostrapped with Python3.7 below. I'm able to successfully run the demo code and a handful of toy examples without issue. Given your code appears to run cleanly on other platforms, this seems like a container specific issue.

If you can add awscrt.io.init_logging(awscrt.io.LogLevel.Error, 'stderr') to the top of your script, that'll add detailed logging for the C code being executed by CRT. If you can provide that here (after cleaning any sensitive info) or reaching out through an AWS support contact with the info, we'll be able to get a clearer look at what's happening.

Example Dockerfile:

FROM ubuntu:16.04
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update && \
    apt-get install -y ubuntu-server && \
    apt-get install software-properties-common && \
    add-apt-repository ppa:deadsnakes/ppa && \
    apt-get update && apt-get install -y python3.7 && \
    apt-get install libpython3.7 && \
    curl https://bootstrap.pypa.io/get-pip.py -o /tmp/get-pip.py && \
    python3.7 /tmp/get-pip.py
anshitmt commented 3 years ago

Hi @nateprewitt ,

Thank you for taking the time to go through the issue. Recently, while experimenting with my Docker file, I installed ssh package, and then the code ran perfectly. So I guess this missing package was the problem.