RTSPtoWeb
RTSPtoWeb copied to clipboard
WebRTC in Docker with no host network mode, Windows 10, WSL2
Hi. Thanks for this great library!
I would like to run the docker as a container, enabling other containers to leverage the WebRTC protocol for accessing the video stream generated by this library..
I'm aware that the documentation recommends running the Docker with the host network mode.
I executed the Docker using the following docker-compose file:
version: "3.3"
services:
application:
# My application setup which is using the streaming service WebRTC
streaming:
image: http://ghcr.io/deepch/rtsptoweb:latest
container_name: streaming
volumes:
- ./RTSPToWeb_Setup/config.json:/config/config.json
restart: always
ports:
- 8083:8083
When I open localhost:8083 on Windows, all streaming protocols runs successfully and shows video (HLS, HLSL, MSE), except WebRTC.
Is there any specific constraint for WebRTC in the Docker file that necessitates running it in host network mode?
My system
- Windows 10
- WSL2
- Docker 25.2
Thanks in advance :)
Yes, needed for WebRTC as you've confirmed.
It seems possible its not needed, but then you need to figure out how to expose all the ports needed by WebRTC -- not sure how tractable that is.
@allenporter thanks for your reply.
I think if we use --network=host
, we can use docker host ip to access the WebRTC endpoint.
Will do a research on it and post the result here :).
try add to compose.yml ports like this:
- 0.0.0.0:50000-50009:50000-50009/udp
and add min max webRTC ports into config.json
"webrtc_port_max": 50009,
"webrtc_port_min": 50000
example compose.yml:
services:
RTSPtoWeb:
image: ghcr.io/deepch/rtsptoweb
container_name: camera-server
ports:
- 0.0.0.0:8089:8083
- 0.0.0.0:50000-50009:50000-50009/udp
- 0.0.0.0:5541:5541
example config.json:
{
"channel_defaults": {},
"server": {
"debug": true,
"http_debug": false,
"http_demo": true,
"http_dir": "web",
"http_login": "demo",
"http_password": "demo",
"http_port": ":8083",
"https": false,
"https_auto_tls": false,
"https_auto_tls_name": "",
"https_cert": "server.crt",
"https_key": "server.key",
"https_port": ":443",
"ice_credential": "",
"ice_servers": [],
"ice_username": "",
"log_level": "debug",
"rtsp_port": ":5541",
"token": {
"backend": "http://127.0.0.1/test.php",
"enable": false
},
"webrtc_port_max": 50009,
"webrtc_port_min": 50000
},
"streams": {
"test": {
"channels": {
"0": {
"debug": true,
"url": "<url_to_rtsp_stream>"
}
},
"name": "test"
}
}
}
try add to compose.yml ports like this:
- 0.0.0.0:50000-50009:50000-50009/udp
and add min max webRTC ports into config.json
"webrtc_port_max": 50009, "webrtc_port_min": 50000
example compose.yml:
services: RTSPtoWeb: image: ghcr.io/deepch/rtsptoweb container_name: camera-server ports: - 0.0.0.0:8089:8083 - 0.0.0.0:50000-50009:50000-50009/udp - 0.0.0.0:5541:5541
example config.json:
{ "channel_defaults": {}, "server": { "debug": true, "http_debug": false, "http_demo": true, "http_dir": "web", "http_login": "demo", "http_password": "demo", "http_port": ":8083", "https": false, "https_auto_tls": false, "https_auto_tls_name": "", "https_cert": "server.crt", "https_key": "server.key", "https_port": ":443", "ice_credential": "", "ice_servers": [], "ice_username": "", "log_level": "debug", "rtsp_port": ":5541", "token": { "backend": "http://127.0.0.1/test.php", "enable": false }, "webrtc_port_max": 50009, "webrtc_port_min": 50000 }, "streams": { "test": { "channels": { "0": { "debug": true, "url": "<url_to_rtsp_stream>" } }, "name": "test" } } }
This didn't work for me, did you manage to get it working?
When I looked into the SDP header it returns
a=candidate:3306701121 1 udp 2130706431 172.20.0.2 50004 typ host
a=candidate:3306701121 2 udp 2130706431 172.20.0.2 50004 typ host
So its not even on the correct IP range...
Is there any updates on this ,or is there a way to know all the ports used by WebRTC?
Is there any updates on this ,or is there a way to know all the ports used by WebRTC?
If you are running your docker on windows then no it doesn't seem possible. I had to run mine thru docker via WSL.
Try to restart container after change in confing.json. Even that, I recommend using mode type "host".
Is there any updates on this ,or is there a way to know all the ports used by WebRTC?
If you are running your docker on windows then no it doesn't seem possible. I had to run mine thru docker via WSL.
I am using WSL2 instead of Windows. Is there a way to run WebRTC without type "host" and only exposing the necessary ports?