ossrs / srs

SRS is a simple, high-efficiency, real-time media server supporting RTMP, WebRTC, HLS, HTTP-FLV, HTTP-TS, SRT, MPEG-DASH, and GB28181.
https://ossrs.io
MIT License
25.69k stars 5.38k forks source link

WebRTC: Play stucked when no Internet. #3463

Open kewell-tsao opened 1 year ago

kewell-tsao commented 1 year ago

Description

SRS Version: v4.0-r4

SRS Log:

[2023-03-13 02:09:06.112][Trace][1][413s303w] query release err  : http: connect server : http: tcp connect http api.ossrs.net:80 to=30000ms, rto=30000ms : tcp: connect api.ossrs.net:80 to=30000ms : get address info
[2023-03-13 02:09:06.112][Trace][1][413s303w] Finish query id=vid-q06122l, session=vid-l7bohx4, eip=172.17.0.4, match=4.0.206, stable=4.0.206, cost=20020ms, url=http://api.ossrs.net/service/v1/releases?version=v4.0.268&id=vid-q06122l&session=vid-l7bohx4&role=srs&eip=172.17.0.4&ts=1678673326092802&alive=3900&os=linux&x86=1&docker=1&packager=dcis&rtc=1&api=1&raw=1&vhosts=1&hooks=1&streams=1&clients=3&recv=1216
[2023-03-13 02:09:06.112][Trace][1][mgzt3ml7] Hybrid cpu=2.00%,21MB, cid=32,3, timer=19,0,31, clock=0,13,2,0,0,0,0,0,0, objs=(pkt:142,raw:67,fua:74,msg:185,oth:1,buf:16)
[2023-03-13 02:09:06.112][Trace][1][mgzt3ml7] RTC: Server conns=2, rpkts=(3,rtp:0,stun:1,rtcp:3), spkts=(62,rtp:62,stun:1,rtcp:0), fid=(id:0,fid:3,ffid:0,addr:1,faddr:3)
[2023-03-13 02:09:06.112][Trace][1][07r57i05] <- RTC RECV #10, udp 7, pps 4/0, schedule 7

Replay

Please describe how to replay the bug?

Step 1: Set up an SRS server using Docker according to the documentation, with no external network connection in the local area network.

objs/srs -c conf/rtmp2rtc.conf

Step 2: Use OBS to push RTMP stream, and play it using Chrome WebRTC Player. The video is normal.

Step 3: Wait for about 10~50 minutes, the video playback in Chrome gets stuck, and SRS logs the above information. OBS streaming is normal.

Control Test 1: Restore external network connection in the local area network, and repeat Step 2 without any abnormalities.

Control Test 2: Disconnect external network connection in the local area network, add the configuration line query_latest_version off;, and repeat Step 2 without any abnormalities.

Expect

The version query feature #2424 should not have any impact on the main business under any circumstances.

winlinvip commented 1 year ago

This is essentially due to the DNS resolution blocking, as referenced in https://github.com/ossrs/srs/issues/2112

The version query will only query an SRS API domain, so it will trigger this issue.

In fact, when RTC uses a domain name, if the callback has a domain name, this issue will also occur.

Therefore, the final solution to this problem is to resolve issue #2112.

Temporary Workarounds:

  1. Turn off version query: query_latest_version off;
  2. Avoid using domain names in callbacks.
  3. Avoid using domain names in RTC, including CANDIDATE and API.
winlinvip commented 7 months ago

Update: We have disabled the version querying by query_latest_version off in SRS 5+, see ee6a68d24ca165d917b26414a4168d265363d9d1 and 84b184dd5309096f9df97967af878ecd7cb36da6