Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebRTC in Docker with no host network mode, Windows 10, WSL2 #419

Open
Ehsan-Home opened this issue Dec 13, 2023 · 9 comments
Open

WebRTC in Docker with no host network mode, Windows 10, WSL2 #419

Ehsan-Home opened this issue Dec 13, 2023 · 9 comments

Comments

@Ehsan-Home
Copy link

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 :)

@allenporter
Copy link
Collaborator

allenporter commented Dec 14, 2023

Yes, needed for WebRTC as you've confirmed.

@allenporter
Copy link
Collaborator

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.

@Ehsan-Home
Copy link
Author

@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 :).

@Sanit93
Copy link

Sanit93 commented Feb 5, 2024

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"
    }
  }
}

@Wolfleader101
Copy link

Wolfleader101 commented Feb 28, 2024

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...

@josemiguely
Copy link

Is there any updates on this ,or is there a way to know all the ports used by WebRTC?

@Wolfleader101
Copy link

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.

@Sanit93
Copy link

Sanit93 commented Mar 11, 2024

Try to restart container after change in confing.json. Even that, I recommend using mode type "host".

@josemiguely
Copy link

josemiguely commented Mar 11, 2024

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants