Unable to Access MediaMTX WebRTC Stream in Minikube Kubernetes Cluster [closed]

Mediamtx webrtc stream is not accessible while running inside k8s cluster in minikube

I am facing an issue while trying to access a MediaMTX WebRTC stream that is deployed inside a Minikube Kubernetes cluster. The deployment seems to be set up correctly, but I cannot access the WebRTC stream, and I am getting a timeout error when trying to establish a connection.

Steps to Replicate the Issue:

  1. Create a Minikube Cluster: Set up a Minikube cluster using the default configuration.

  2. Deploy MediaMTX: Deploy the following resources: a Deployment, a Service, and a ConfigMap.

The Config map include custom mediamtx.yml config

Mediamtx Deployment

apiVersion: apps/v1
kind: Deployment
metadata:
  name: mediamtx
  labels:
    app: mediamtx
spec:
  replicas: 1
  selector:
    matchLabels:
      app: mediamtx
  template:
    metadata:
      labels:
        app: mediamtx
    spec:
      containers:
      - name: mediamtx
        image: bluenviron/mediamtx
        args: ["/mediamtx.yml"] # Explicitly specify the config file location
        volumeMounts:
        - name: config
          mountPath: /mediamtx.yml
          subPath: mediamtx.yml
        ports:
        - containerPort: 8554
        - containerPort: 1935
        - containerPort: 8888
        - containerPort: 8889
        - containerPort: 8890
        - containerPort: 8189
        env:
        - name: MTX_PROTOCOLS
          value: "tcp"
        - name: MTX_WEBRTCADDITIONALHOSTS
          value: "172.19.0.1" # Adjust as needed
      volumes:
      - name: config
        configMap:
          name: mediamtx-config
          defaultMode: 0644  # Ensure the file is readable

Mediamtx Service

apiVersion: v1
kind: Service
metadata:
  name: mediamtx
spec:
  type: ClusterIP
  ports:
    - name: rtsp
      port: 8554
      targetPort: 8554
      protocol: TCP
    - name: rtmp
      port: 1935
      targetPort: 1935
      protocol: TCP
    - name: web
      port: 8888
      targetPort: 8888
      protocol: TCP
    - name: web-rtc
      port: 8889
      targetPort: 8889
      protocol: TCP
    - name: rtsp-udp
      port: 8890
      targetPort: 8890
      protocol: UDP
    - name: udp-extra
      port: 8189
      targetPort: 8189
      protocol: UDP
  selector:
    app: mediamtx

mediamtx config map

apiVersion: v1
kind: ConfigMap
metadata:
  name: mediamtx-config
data:
  mediamtx.yml: |
    paths:
      mycamera:
        source: rtsp://admin:[email protected]:554/unicaststream/1
  1. The Config map includes custom mediamtx configuration. I have added a default rtsp stream path entry to it, And trying to access the corresponding webrtc streams.

  2. Apply all resources, wait for medamtx pod to start. Expose mediamtx service using kubectl port-forward

  3. Now the webrtc stream should be accessible at http://localhost:8889/mycamera, But I am not able to access it

Server Logs

Mediamtx server logs before trying to access webrtc stream
2024/09/24 06:49:37 INF MediaMTX v1.9.0
2024/09/24 06:49:37 INF configuration loaded from /mediamtx.yml
2024/09/24 06:49:37 INF [path matrixcamera] [RTSP source] started
2024/09/24 06:49:37 INF [RTSP] listener opened on :8554 (TCP)
2024/09/24 06:49:37 INF [RTMP] listener opened on :1935
2024/09/24 06:49:37 INF [HLS] listener opened on :8888
2024/09/24 06:49:37 INF [WebRTC] listener opened on 0.0.0.0:8889 (HTTP), :8189 (ICE/UDP)
2024/09/24 06:49:37 INF [SRT] listener opened on :8890 (UDP)
2024/09/24 06:49:37 INF [path matrixcamera] [RTSP source] ready: 2 tracks (H264, G711)

Mediamtx server logs after trying to access webrtc stream
2024/09/24 07:15:24 INF [WebRTC] [session 8b9d0424] created by 127.0.0.1:52060
2024/09/24 07:15:34 INF [WebRTC] [session 8b9d0424] closed: deadline exceeded while waiting connection

I am trying to access the stream at localhost:8889/mycamera after running kubectl port-forward svc/mediamtx 8889:8889

I also tried adding stun/turn server in mediamtx config

# webrtcICEServers2:
# - url: stun:stun2.1.google.com:19302

Also tried adding webrtc address as broadcast in mediamtx config

# rtspAddress: 0.0.0.0:8554

Still I am unable to acesss I get following errrors in browser console

DELETE http://localhost:8889/matrixcamera/whep/adcf8e30-a171-4843-bfa0-8b2522b86abe 404 (Not Found)
onError @ matrixcamera/:368
onConnectionState @ matrixcamera/:490
pc.oniceconnectionstatechange @ matrixcamera/:515
favicon.ico:1

The whep DELETE request always timesout

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật