WebRTC NAT #3468
WebRTC NAT
#3468
Replies: 1 comment 1 reply
-
I see that you are using the IP Address in "webrtcAdditionalHosts: [1.92.137.138]" I seem to remember having a similar issue because WebRTC uses HTTPS to reach the server. And if the certificate uses the hostname it cant connect. Try adding the hostname along with it.
|
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Question
I want to use the browser webrtc to access rtsp streams over TCP network. Now I can access rtsp over TCP network, but when I use the browser, the connection fails. I also set up my yml file according to Solving WebRTC connectivity issues in the README file, but it still doesn't work. Below is my yml file and my error message.I am using mediamtx v1.8.2。
This is my config file
###############################################
Global settings -> WebRTC server
Enable publishing and reading streams with the WebRTC protocol.
webrtc: yes
Address of the WebRTC HTTP listener.
webrtcAddress: :8889
Enable TLS/HTTPS on the WebRTC server.
webrtcEncryption: no
Path to the server key.
This can be generated with:
openssl genrsa -out server.key 2048
openssl req -new -x509 -sha256 -key server.key -out server.crt -days 3650
webrtcServerKey: server.key
Path to the server certificate.
webrtcServerCert: server.crt
Value of the Access-Control-Allow-Origin header provided in every HTTP response.
This allows to play the WebRTC stream from an external website.
webrtcAllowOrigin: '*'
List of IPs or CIDRs of proxies placed before the WebRTC server.
If the server receives a request from one of these entries, IP in logs
will be taken from the X-Forwarded-For header.
webrtcTrustedProxies: []
Address of a local UDP listener that will receive connections.
Use a blank string to disable.
webrtcLocalUDPAddress: :8189
Address of a local TCP listener that will receive connections.
This is disabled by default since TCP is less efficient than UDP and
introduces a progressive delay when network is congested.
webrtcLocalTCPAddress: :8189
WebRTC clients need to know the IP of the server.
Gather IPs from interfaces and send them to clients.
webrtcIPsFromInterfaces: yes
List of interfaces whose IPs will be sent to clients.
An empty value means to use all available interfaces.
webrtcIPsFromInterfacesList: []
List of additional hosts or IPs to send to clients.
webrtcAdditionalHosts: [1.92.137.138]
ICE servers. Needed only when local listeners can't be reached by clients.
STUN servers allows to obtain and share the public IP of the server.
TURN/TURNS servers forces all traffic through them.
webrtcICEServers2:
if user is "AUTH_SECRET", then authentication is secret based.
the secret must be inserted into the password field.
username: 'pi4'
password: '123'
clientOnly: false
###############################################
This is my display
`./mediamtx
2024/06/14 18:59:50 INF MediaMTX v1.8.2
2024/06/14 18:59:50 INF configuration loaded from /home/pi4/mediamtx/mediamtx.yml
2024/06/14 18:59:50 INF [path cam1] runOnInit command started
2024/06/14 18:59:50 INF [RTSP] listener opened on :8554 (TCP), :8000 (UDP/RTP), :8001 (UDP/RTCP)
2024/06/14 18:59:50 INF [RTMP] listener opened on :1935
2024/06/14 18:59:50 INF [HLS] listener opened on :8888
2024/06/14 18:59:50 INF [WebRTC] listener opened on :8889 (HTTP), :8189 (ICE/UDP), :8189 (ICE/TCP)
2024/06/14 18:59:50 INF [SRT] listener opened on :8890 (UDP)
ffmpeg version 4.4.2-0ubuntu0.22.04.1 Copyright (c) 2000-2021 the FFmpeg developers
built with gcc 11 (Ubuntu 11.2.0-19ubuntu1)
configuration: --prefix=/usr --extra-version=0ubuntu0.22.04.1 --toolchain=hardened --libdir=/usr/lib/aarch64-linux-gnu --incdir=/usr/include/aarch64-linux-gnu --arch=arm64 --enable-gpl --disable-stripping --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzimg --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-pocketsphinx --enable-librsvg --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
libavutil 56. 70.100 / 56. 70.100
libavcodec 58.134.100 / 58.134.100
libavformat 58. 76.100 / 58. 76.100
libavdevice 58. 13.100 / 58. 13.100
libavfilter 7.110.100 / 7.110.100
libswscale 5. 9.100 / 5. 9.100
libswresample 3. 9.100 / 3. 9.100
libpostproc 55. 9.100 / 55. 9.100
[0:04:08.567155595] [2076] INFO Camera camera_manager.cpp:284 libcamera v0.2.0+120-eb00c13d
[0:04:08.618149568] [2078] WARN RPiSdn sdn.cpp:40 Using legacy SDN tuning - please consider moving SDN inside rpi.denoise
[0:04:08.622185347] [2078] WARN RPI vc4.cpp:392 Mismatch between Unicam and CamHelper for embedded data usage!
[0:04:08.623490445] [2078] INFO RPI vc4.cpp:446 Registered camera /base/soc/i2c0mux/i2c@1/imx219@10 to Unicam device /dev/media0 and ISP device /dev/media1
[0:04:08.623577227] [2078] INFO RPI pipeline_base.cpp:1102 Using configuration file '/usr/local/share/libcamera/pipeline/rpi/vc4/rpi_apps.yaml'
Mode selection for 1280:720:12:P
SRGGB10_CSI2P,640x480/0 - Score: 4093.33
SRGGB10_CSI2P,1640x1232/0 - Score: 2557.83
SRGGB10_CSI2P,1920x1080/0 - Score: 1250
SRGGB10_CSI2P,3280x2464/0 - Score: 3275.83
SRGGB8,640x480/0 - Score: 5093.33
SRGGB8,1640x1232/0 - Score: 3557.83
SRGGB8,1920x1080/0 - Score: 2250
SRGGB8,3280x2464/0 - Score: 4275.83
[0:04:08.627076685] [2076] INFO Camera camera.cpp:1183 configuring streams: (0) 1280x720-YUV420 (1) 1920x1080-SBGGR10_CSI2P
[0:04:08.627721882] [2078] INFO RPI vc4.cpp:621 Sensor: /base/soc/i2c0mux/i2c@1/imx219@10 - Selected sensor format: 1920x1080-SBGGR10_1X10 - Selected unicam format: 1920x1080-pBAA
Input #0, rawvideo, from '/dev/stdin':
Duration: N/A, start: 0.000000, bitrate: 276480 kb/s
Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 1280x720, 276480 kb/s, 25 tbr, 25 tbn, 25 tbc
Stream mapping:
Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (h264_v4l2m2m))
[h264_v4l2m2m @ 0xaaab030d8970] Using device /dev/video11
[h264_v4l2m2m @ 0xaaab030d8970] driver 'bcm2835-codec' on card 'bcm2835-codec-encode' in mplane mode
[h264_v4l2m2m @ 0xaaab030d8970] requesting formats: output=YU12 capture=H264
[h264_v4l2m2m @ 0xaaab030d8970] Failed to set gop size: Invalid argument
2024/06/14 18:59:51 INF [RTSP] [conn [::1]:60062] opened
2024/06/14 18:59:51 INF [RTSP] [session 414bb22e] created by [::1]:60062
2024/06/14 18:59:51 INF [RTSP] [session 414bb22e] is publishing to path 'cam1', 1 track (H264)
Output #0, rtsp, to 'rtsp://localhost:8554/cam1':
Metadata:
encoder : Lavf58.76.100
Stream #0:0: Video: h264, yuv420p(progressive), 1280x720, q=2-31, 2000 kb/s, 25 fps, 90k tbn
Metadata:
encoder : Lavc58.134.100 h264_v4l2m2m
[rtsp @ 0xaaab030d52f0] Non-monotonous DTS in output stream 0:0; previous: 0, current: 0; changing to 1. This may result in incorrect timestamps in the output file.
2024/06/14 19:00:21 INF [WebRTC] [session aa28d5b8] created by 127.0.0.1:57098
2024/06/14 19:00:21 INF [WebRTC] [session aa28d5b8] peer connection established, local candidate: host/udp/1.92.137.138/8189, remote candidate: srflx/udp/183.198.200.115/26257
2024/06/14 19:00:21 INF [WebRTC] [session aa28d5b8] is reading from path 'cam1', 1 track (H264)
2024/06/14 19:00:33 INF [WebRTC] [session aa28d5b8] closed: peer connection closed
2024/06/14 19:05:13 INF [RTSP] [conn 127.0.0.1:58600] opened=N/A speed= 1.2x
2024/06/14 19:05:13 INF [RTSP] [session f05a1f4d] created by 127.0.0.1:58600
2024/06/14 19:05:14 INF [RTSP] [session f05a1f4d] is reading from path 'cam1', with UDP, 1 track (H264)
2024/06/14 19:05:19 INF [RTSP] [session f05a1f4d] destroyed: torn down by 127.0.0.1:58600
2024/06/14 19:05:19 INF [RTSP] [conn 127.0.0.1:58600] closed: EOF
2024/06/14 19:05:19 INF [RTSP] [conn 127.0.0.1:49122] opened
2024/06/14 19:05:19 INF [RTSP] [session d4ba9c6d] created by 127.0.0.1:49122
2024/06/14 19:05:20 INF [RTSP] [session d4ba9c6d] is reading from path 'cam1', with TCP, 1 track (H264)
2024/06/14 19:05:22 INF [RTSP] [session d4ba9c6d] destroyed: torn down by 127.0.0.1:49122
2024/06/14 19:05:22 INF [RTSP] [conn 127.0.0.1:49122] closed: EOF
2024/06/14 19:05:41 INF [WebRTC] [session c301306b] created by 127.0.0.1:51406
2024/06/14 19:05:42 INF [WebRTC] [session c301306b] peer connection established, local candidate: host/udp/1.92.137.138/8189, remote candidate: prflx/udp/192.168.198.221/64689
2024/06/14 19:05:42 INF [WebRTC] [session c301306b] is reading from path 'cam1', 1 track (H264)
2024/06/14 19:05:51 INF [WebRTC] [session c301306b] closed: peer connection closed
**
**
`
I can access it using the public IP in the local area network, but when I use the public IP in other networks, it shows that the connection failed
Beta Was this translation helpful? Give feedback.
All reactions