bluenviron / mediamtx

Ready-to-use SRT / WebRTC / RTSP / RTMP / LL-HLS media server and media proxy that allows to read, publish, proxy, record and playback video and audio streams.
MIT License
10.75k stars 1.4k forks source link

[WebRTC] UDP Peer connection issue with non-chromium browsers when client is connect to VPN #3522

Open mrlt8 opened 3 days ago

mrlt8 commented 3 days ago

Which version are you using?

v1.8.3

Which operating system are you using?

Describe the issue

This issue affects WebRTC clients using Safari (iOS/macOS) and WebKit-based browsers like Chrome on iOS.

WebRTC works as intended in these browsers when NOT connected to a VPN. However, the peer connection fails when the client device is connected to a VPN.

Chromium-based browsers such as Arc, Brave, Chrome, and Opera are not affected by this issue and continue to work with and without the VPN on the same device without any issues.

Firefox is inconsistent when a VPN is enabled. It usually works after reloading the page. Unlike Chromium-based browsers, WebRTC in Firefox only works when using the server's IP address and does not work with loopback addresses like 127.0.0.1 or localhost when connected to a VPN, although these addresses work when not connected to the VPN.

Setting webrtcLocalTCPAddress resolves the issue for WebKit (issues with firefox remain unchanged), which leads me to believe it's some kind of UDP peer issue in WebKit.

Describe how to replicate the issue

  1. Start a path in MediaMTX:
    docker run --rm -it \
    -e MTX_PATHS_TEST_RUNONINIT="ffmpeg -loglevel error -re -f lavfi -i color=c=blue:s=640x480:r=5 -c:v libx264 -g 1 -f rtsp rtsp://127.0.0.1:8554/test" \
    -e MTX_WEBRTCADDITIONALHOSTS=10.0.0.43 \
    -p 8189:8189/udp -p 8889:8889 bluenviron/mediamtx:1.8.3-ffmpeg
  2. Confirm WebRTC streams work in a WebKit-based browser and Chromium-based browser
  3. Connect to a VPN like 1.1.1.1 warp or windscribe.
  4. Attempt to open the WebRTC stream in a WebKit-based browser and Chromium-based browser

Did you attach the server logs?

DEB [WebRTC] [session 7d5b5c17] peer connection state: closed
INF [WebRTC] [session 7d5b5c17] closed: deadline exceeded while waiting connection

Did you attach a network dump?

no

JA16122000 commented 2 days ago

Looks the same issue as: https://github.com/bluenviron/mediamtx/issues/3525 ?