whitphx / streamlit-webrtc

Real-time video and audio processing on Streamlit
https://discuss.streamlit.io/t/new-component-streamlit-webrtc-a-new-way-to-deal-with-real-time-media-streams/8669
MIT License
1.38k stars 184 forks source link

Key Type Error When Starting Video Feed in WSL2 #1186

Open ilhamfadhil14 opened 1 year ago

ilhamfadhil14 commented 1 year ago

I'm trying to replicate simple version of streamlit_webrtc using this code:

from streamlit_webrtc import webrtc_streamer

webrtc_streamer(key='sample')

When I started the video feed in streamlit, it results following error:

image

2023-02-09 09:17:16.623 Uncaught app exception
Traceback (most recent call last):
  File "/home/ilhamfadhil/miniconda3/envs/recognice_demo/lib/python3.9/site-packages/streamlit/scriptrunner/script_runner.py", line 557, in _run_script
    exec(code, module.__dict__)
  File "webrtc_test.py", line 3, in <module>
    webrtc_streamer(key='sample')
  File "/home/ilhamfadhil/miniconda3/envs/recognice_demo/lib/python3.9/site-packages/streamlit_webrtc/component.py", line 568, in webrtc_streamer
    webrtc_worker = WebRtcWorker(
  File "/home/ilhamfadhil/miniconda3/envs/recognice_demo/lib/python3.9/site-packages/streamlit_webrtc/webrtc.py", line 375, in __init__
    self.pc = RTCPeerConnection()
  File "/home/ilhamfadhil/miniconda3/envs/recognice_demo/lib/python3.9/site-packages/aiortc/rtcpeerconnection.py", line 294, in __init__
    self.__certificates = [RTCCertificate.generateCertificate()]
  File "/home/ilhamfadhil/miniconda3/envs/recognice_demo/lib/python3.9/site-packages/aiortc/rtcdtlstransport.py", line 156, in generateCertificate
    key=crypto.PKey.from_cryptography_key(key),
  File "/home/ilhamfadhil/miniconda3/envs/recognice_demo/lib/python3.9/site-packages/OpenSSL/crypto.py", line 274, in from_cryptography_key
    raise TypeError("Unsupported key type")
TypeError: Unsupported key type

When I tried replicate this issue using tutorial for simple webrtc python using this tutorial. The video stream works.

My guess is related to either WSL2 networking configuration or this issue https://github.com/whitphx/streamlit-webrtc/issues/1164

Development environment:

whitphx commented 1 year ago

Thank you for the report! Let me take time to check it.

araii commented 1 year ago

Hi @whitphx, was testing the webrtc component in streamlit today and I got the same error, - but strangely it was working for me last week - but this issue was '3 weeks ago' ?

I also posted on streamlit's forum to seek help, sorry for multiple post. https://discuss.streamlit.io/t/streamlit-webrtc-error-unsupported-key-type-error-in-from-cryptography-key-in-python3-9-site-packages-openssl-crypto-py-file/38594?u=a_lj

Screenshot 2023-03-02 at 16 09 05

and I have updated streamlit to version 1.19.0 and streamlit-webrtc to version 0.44.7, but i’m still facing the same issue. Please guide me on what to do in order to resolve this. Thank you.

araii commented 1 year ago

Manage to get webrtc running in streamlit again. Not sure if this is the solution, @whitphx - but this works for now.

I found that my issue was related to an outdated version of pyOpenSSL -

current version was 23.0.0 and the version in my conda was 22.0.0 - so i had to update it - using pip didn't work for me, so i used conda

conda install -c conda-forge pyopenssl