whitphx / streamlit-webrtc

Real-time video and audio streams over the network, with Streamlit.
https://discuss.streamlit.io/t/new-component-streamlit-webrtc-a-new-way-to-deal-with-real-time-media-streams/8669
MIT License
1.27k stars 176 forks source link

How can i use docker for deploy? #1126

Open nrtpkim opened 1 year ago

nrtpkim commented 1 year ago

when I start docker I cannot open the camera and then I open the camera, error show below

`/usr/local/lib/python3.9/site-packages/aiortc/rtcdtlstransport.py:211: CryptographyDeprecationWarning: This version of cryptography contains a temporary pyOpenSSL fallback path. Upgrade pyOpenSSL now. _openssl_assert(lib.SSL_CTX_use_certificate(ctx, self._cert._x509) == 1) # type: ignore 2022-11-11 10:59:02.255 Track video received 2022-11-11 10:59:02.255 Set <aiortc.rtcrtpreceiver.RemoteStreamTrack object at 0x7f7cb2a4dd00> as an input video track with video_processor <class 'streamlit_webrtc.process.AsyncVideoProcessTrack'> 2022-11-11 10:59:02.255 Add a track <streamlit_webrtc.process.AsyncVideoProcessTrack object at 0x7f7cb2a51730> of kind video to <aiortc.rtcpeerconnection.RTCPeerConnection object at 0x7f7cb3af6cd0> /usr/local/lib/python3.9/site-packages/aiortc/rtcdtlstransport.py:186: CryptographyDeprecationWarning: This version of cryptography contains a temporary pyOpenSSL fallback path. Upgrade pyOpenSSL now. value=certificate_digest(self._cert._x509), # type: ignore 2022-11-11 10:59:02.292 Connection(0) Check CandidatePair(('172.24.0.3', 37908) -> ('192.168.0.117', 65137)) State.FROZEN -> State.WAITING 2022-11-11 10:59:02.293 ICE connection state is checking 2022-11-11 10:59:02.293 Connection(0) Check CandidatePair(('172.24.0.3', 37908) -> ('192.168.0.117', 65137)) State.WAITING -> State.IN_PROGRESS 2022-11-11 10:59:17.594 ICE connection state is closed 2022-11-11 10:59:17.899 Exception in callback Transaction.retry() handle: <TimerHandle when=16114.24134038 Transaction.retry()> Traceback (most recent call last): File "/usr/local/lib/python3.9/asyncio/selector_events.py", line 1054, in sendto self._sock.sendto(data, addr) AttributeError: 'NoneType' object has no attribute 'sendto'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/local/lib/python3.9/asyncio/events.py", line 80, in _run self._context.run(self._callback, *self._args) File "/usr/local/lib/python3.9/site-packages/aioice/stun.py", line 309, in retry self.protocol.send_stun(self.request, self.addr) File "/usr/local/lib/python3.9/site-packages/aioice/ice.py", line 243, in send_stun self.transport.sendto(bytes(message), addr) File "/usr/local/lib/python3.9/asyncio/selector_events.py", line 1064, in sendto self._fatal_error( File "/usr/local/lib/python3.9/asyncio/selector_events.py", line 711, in _fatal_error self._loop.call_exception_handler({ AttributeError: 'NoneType' object has no attribute 'call_exception_handler'`

whitphx commented 1 year ago

I cannot open the camera and then I open the camera

Please elaborate it. What does "I cannot open the camera" and "then I open the camera" mean?


Note: A large part of the error message is about an exception subsequently raised after the main problem like the case at https://github.com/whitphx/streamlit-webrtc/issues/552#issuecomment-1108781763

nrtpkim commented 1 year ago

Sorry for my miscommunication.

moono commented 1 year ago

You should first check if your client PC has allowed UDP ports.

I had similar problem like OP and installed coturn (turn/stun server) and everything but nothing worked. My problem was that I was using Windows 10 as client (which tries to connect stream_webrtc installed docker container on company's cloud infrastructure), I had to allow UDP ports range: 49152 - 65535 to get it working. No turn / stun server needed.

And yes if you deployed your application in some public cloud than you need a turn/stun server.

Another note is that if the your first attempt didn't worked, than try again, than it works. Every time I test with chrome's incognito tab, I had to press start twice to get it working.

yusuf-jkhan1 commented 1 year ago

@whitphx can you provide a dockerfile example for deployment? I am also getting this error. I went down a google spiral trying to figure out how to install a sound card server inside the docker container.