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.9k stars 1.41k forks source link

webrtc don't work #2621

Closed pikachu937 closed 7 months ago

pikachu937 commented 8 months ago

Which version are you using?

v1.X.X and later

Which operating system are you using?

Describe the issue

Description

Since version 1.X.X, in the old version of the chrome browser (66 and up to 74), webrtc links (https://external-ip:port/stream) no longer open, the browser cannot log in and, as a result, a black screen is visible. the same problem on phones with the android 9(pie) operating system. It’s not difficult to update the browser on a computer to version 75, but on a phone it’s quite problematic.

in version 0.23.8 everything works fine

log from server

2023/11/01 16:27:36 DEB [WebRTC] [conn X.X.X.X:11470] OPTIONS /path1/whep
2023/11/01 16:27:36 DEB [WebRTC] [conn X.X.X.X:11470] [c->s] OPTIONS /path1/whep?controls=0 HTTP/2.0
Host: external-ip:port
Accept: */*
Accept-Encoding: gzip, deflate, br
Accept-Language: ru-RU,ru;q=0.9,en-US;q=0.8,en;q=0.7
Origin: https://external-ip:port
Referer: https://external-ip:port/path1/?controls=0
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36

2023/11/01 16:27:36 DEB [WebRTC] [conn X.X.X.X:11470] [s->c] HTTP/1.1 401 Unauthorized
Access-Control-Allow-Credentials: true
Access-Control-Allow-Origin: *
Server: mediamtx
Www-Authenticate: Basic realm="mediamtx"

2023/11/01 16:27:38 DEB [WebRTC] [conn X.X.X.X:11470] OPTIONS /path1/whep
2023/11/01 16:27:38 DEB [WebRTC] [conn X.X.X.X:11470] [c->s] OPTIONS /path1/whep?controls=0 HTTP/2.0
Host: external-ip:port
Accept: */*
Accept-Encoding: gzip, deflate, br
Accept-Language: ru-RU,ru;q=0.9,en-US;q=0.8,en;q=0.7
Origin: https://external-ip:port
Referer: https://external-ip:port/path1/?controls=0
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36

2023/11/01 16:27:38 DEB [WebRTC] [conn X.X.X.X:11470] [s->c] HTTP/1.1 401 Unauthorized
Access-Control-Allow-Credentials: true
Access-Control-Allow-Origin: *
Server: mediamtx
Www-Authenticate: Basic realm="mediamtx"

2023/11/01 16:27:40 DEB [WebRTC] [conn X.X.X.X:11470] OPTIONS /path1/whep
2023/11/01 16:27:40 DEB [WebRTC] [conn X.X.X.X:11470] [c->s] OPTIONS /path1/whep?controls=0 HTTP/2.0
Host: external-ip:port
Accept: */*
Accept-Encoding: gzip, deflate, br
Accept-Language: ru-RU,ru;q=0.9,en-US;q=0.8,en;q=0.7
Origin: https://external-ip:port
Referer: https://external-ip:port/path1/?controls=0
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36

log from android 9

requesting ICE servers
:port/favicon.ico:1 Failed to load resource: the server responded with a status of 404 ()
:port/path1/whep?controls=0:1 Failed to load resource: the server responded with a status of 401 ()
?controls=0:115 error: TypeError: this.pc.addTransceiver is not a function
?controls=0:108 requesting ICE servers
:port/path1/whep?controls=0:1 Failed to load resource: the server responded with a status of 401 ()
?controls=0:115 error: TypeError: this.pc.addTransceiver is not a function
?controls=0:108 requesting ICE servers
?controls=0:110 OPTIONS https://external-ip:port/path1/whep?controls=0 401 ()
start @ ?controls=0:110
restartTimeout.window.setTimeout @ ?controls=0:243
?controls=0:115 error: TypeError: this.pc.addTransceiver is not a function
?controls=0:108 requesting ICE servers
?controls=0:110 OPTIONS https://external-ip:port/path1/whep?controls=0 401 ()
start @ ?controls=0:110
restartTimeout.window.setTimeout @ ?controls=0:243
setTimeout (async)
scheduleRestart @ ?controls=0:241
fetch.then.catch @ ?controls=0:116
Promise.catch (async)
start @ ?controls=0:114
restartTimeout.window.setTimeout @ ?controls=0:243
?controls=0:115 error: TypeError: this.pc.addTransceiver is not a function
?controls=0:108 requesting ICE servers
?controls=0:110 OPTIONS https://external-ip:port/path1/whep?controls=0 401 ()

log from browser on pc

scheduleRestart @ ?controls=0:285
fetch.then.catch @ ?controls=0:158
Promise.catch (async)
start @ ?controls=0:156
restartTimeout.window.setTimeout @ ?controls=0:287
setTimeout (async)
scheduleRestart @ ?controls=0:285
fetch.then.catch @ ?controls=0:158
Promise.catch (async)
start @ ?controls=0:156
restartTimeout.window.setTimeout @ ?controls=0:287
?controls=0:157 error: TypeError: this.pc.addTransceiver is not a function
?controls=0:150 requesting ICE servers
?controls=0:152 
start @ ?controls=0:152
restartTimeout.window.setTimeout @ ?controls=0:287
setTimeout (async)
scheduleRestart @ ?controls=0:285
fetch.then.catch @ ?controls=0:158
Promise.catch (async)
start @ ?controls=0:156
restartTimeout.window.setTimeout @ ?controls=0:287
setTimeout (async)
scheduleRestart @ ?controls=0:285
fetch.then.catch @ ?controls=0:158
Promise.catch (async)
start @ ?controls=0:156
restartTimeout.window.setTimeout @ ?controls=0:287
setTimeout (async)
scheduleRestart @ ?controls=0:285
fetch.then.catch @ ?controls=0:158
Promise.catch (async)
start @ ?controls=0:156
restartTimeout.window.setTimeout @ ?controls=0:287
setTimeout (async)
scheduleRestart @ ?controls=0:285
fetch.then.catch @ ?controls=0:158

While examining the code, I discovered that the js part in webrtc_read_index.html had been changed

Describe how to replicate the issue

  1. start the server
  2. publish with rtsp
  3. read with browser(android9 phone or pc)

Did you attach the server logs?

yes / no

Did you attach a network dump?

yes / no

pikachu937 commented 8 months ago

aler9 please help me fix this bug

pikachu937 commented 8 months ago

UPD. I apologize if I misled you. Swears on the ice server, from updated information.

"error: InvalidStateError: Failed to execute 'addTransceiver' on 'RTCPeerConnection': This operation is only supported in 'unified-plan'. 'unified-plan' will become the default behavior in the future, but it is currently experimental. To try it out, construct the RTCPeerConnection with sdpSemantics:'unified-plan' present in the RTCConfiguration argument.", source: https://external-ip:port/path1/ (116)
aler9 commented 7 months ago

Hello, after digging i found out the explanation for this problem. Even though it involves a small number of users, i added the sdpSemantics parameter inside the server in order to support Chrome versions older than M72.

github-actions[bot] commented 6 months ago

This issue is mentioned in release v1.4.1 🚀 Check out the entire changelog by clicking here

github-actions[bot] commented 2 weeks ago

This issue is being locked automatically because it has been closed for more than 6 months. Please open a new issue in case you encounter a similar problem.