Skip to content

RTC: When mapping ports in Docker, changing to other ports will fail. #2907

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
LUOQING1994 opened this issue Feb 9, 2022 · 5 comments
Closed
Assignees
Labels
Bug It might be a bug. TransByAI Translated by AI/GPT. WebRTC WebRTC, RTC2RTMP or RTMP2RTC.
Milestone

Comments

@LUOQING1994
Copy link

LUOQING1994 commented Feb 9, 2022

Description

After pulling ossrs/srs:4, deploy it in CentOS 8 and use nginx for forwarding. FLV and HLS can be played normally, but WebRTC cannot be played.

  1. SRS Version: SRS/4.0.231(Leo)

  2. The log of SRS is as follows:

[2022-02-09 09:23:48.071][Trace][1][f9st51j6] RTC local answer: v=0\r\no=SRS/4.0.231(Leo) 47158928 2 IN IP4 0.0.0.0\r\ns=SRSPlaySession\r\nt=0 0\r\na=ice-lite\r\na=group:BUNDLE 0 1\r\na=msid-semantic: WMS SZJY/SZJY76\r\nm=audio 9 UDP/TLS/RTP/SAVPF 111\r\nc=IN IP4 0.0.0.0\r\na=ice-ufrag:ypq728v0\r\na=ice-pwd:6642s32o24h85g4z3w2w912435l02s18\r\na=fingerprint:sha-256 1A:F7:4E:8E:0A:E9:82:E6:DA:9A:8A:08:88:BE:B1:21:E5:84:D1:2E:24:21:75:CE:83:96:E0:45:8B:7A:B0:D3\r\na=setup:passive\r\na=mid:0\r\na=extmap:3 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01\r\na=sendonly\r\na=rtcp-mux\r\na=rtcp-rsize\r\na=rtpmap:111 opus/48000/2\r\na=rtcp-fb:111 transport-cc\r\na=ssrc:10104 cname:ud732780b2717774\r\na=ssrc:10104 label:audio-9723np8t\r\na=candidate:0 1 udp 2130706431 118.123.213.231 8000 typ host generation 0\r\nm=video 9 UDP/TLS/RTP/SAVPF 125\r\nc=IN IP4 0.0.0.0\r\na=ice-ufrag:ypq728v0\r\na=ice-pwd:6642s32o24h85g4z3w2w912435l02s18\r\na=fingerprint:sha-256 1A:F7:4E:8E:0A:E9:82:E6:DA:9A:8A:08:88:BE:B1:21:E5:84:D1:2E:24:21:75:CE:83:96:E0:45:8B:7A:B0:D3\r\na=setup:passive\r\na=mid:1\r\na=extmap:3 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01\r\na=sendonly\r\na=rtcp-mux\r\na=rtcp-rsize\r\na=rtpmap:125 H264/90000\r\na=rtcp-fb:125 transport-cc\r\na=rtcp-fb:125 nack\r\na=rtcp-fb:125 nack pli\r\na=fmtp:125 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f\r\na=ssrc:10105 cname:ud732780b2717774\r\na=ssrc:10105 label:video-08y089b3\r\na=candidate:0 1 udp 2130706431 118.123.213.231 8000 typ host generation 0\r\n
[2022-02-09 09:23:48.082][Trace][1][f9st51j6] TCP: before dispose resource(HttpsConn)(0x2c65340), conns=2, zombies=0, ign=0, inz=0, ind=0
[2022-02-09 09:23:48.082][Warn][1][f9st51j6][104] client disconnect peer. ret=1007
[2022-02-09 09:23:48.082][Trace][1][w3779gpf] TCP: clear zombies=1 resources, conns=2, removing=0, unsubs=0
[2022-02-09 09:23:48.082][Trace][1][f9st51j6] TCP: disposing #0 resource(HttpsConn)(0x2c65340), conns=2, disposing=1, zombies=0
[2022-02-09 09:23:48.401][Trace][1][55f81ojr] Hybrid cpu=1.00%,15MB, cid=2,1, timer=62,0,1, clock=0,46,2,0,0,0,0,0,0, free=1, objs=(pkt:66,raw:1,fua:66,msg:142,oth:1,buf:1)
[2022-02-09 09:23:48.401][Trace][1][55f81ojr] RTC: Server conns=1
[2022-02-09 09:23:51.693][Trace][1][195lg7v9] -> HLS time=30046123ms, sno=4, ts=SZJY76-3.ts, dur=6053ms, dva=0p
[2022-02-09 09:23:53.402][Trace][1][55f81ojr] Hybrid cpu=0.00%,16MB, cid=2,1, timer=62,0,1, clock=0,46,2,0,0,0,0,0,0, free=1, objs=(pkt:66,raw:1,fua:66,msg:142,oth:1,buf:1)
[2022-02-09 09:23:53.402][Trace][1][55f81ojr] RTC: Server conns=1
[2022-02-09 09:23:58.403][Trace][1][55f81ojr] Hybrid cpu=2.00%,16MB, cid=1,0, timer=62,0,49, clock=0,46,2,0,0,0,0,0,0, objs=(pkt:68,raw:1,fua:67,msg:143,oth:1,buf:1)
[2022-02-09 09:23:58.403][Trace][1][f9st51j6] RTC: session destroy by timeout, username=ypq728v0:uB6B
[2022-02-09 09:23:58.403][Trace][1][f9st51j6] RTC: before dispose resource(RtcConn)(0x2cf9690), conns=1, zombies=0, ign=0, inz=0, ind=0
[2022-02-09 09:23:58.403][Trace][1][f9st51j6] RTC: session detach from [f9st51j6](RtcConn), disposing=1
[2022-02-09 09:23:58.403][Trace][1][57448q86] RTC: clear zombies=1 resources, conns=1, removing=0, unsubs=0
[2022-02-09 09:23:58.403][Trace][1][f9st51j6] RTC: disposing #0 resource(RtcConn)(0x2cf9690), conns=1, disposing=1, zombies=0
[2022-02-09 09:23:58.403][Warn][1][f9st51j6][11][DTLS_HANG] DTLS: Hang, done=0, version=-1, arq=0
[2022-02-09 09:24:01.702][Trace][1][195lg7v9] <- CPB time=35003945, okbps=0,0,0, ikbps=518,520,0, mr=0/350, p1stpt=20000, pnt=5000

  1. The configuration of SRS is as follows:
listen              1935;
max_connections     1000;
daemon              off;
srs_log_tank        console;
#pid                 objs/origin.pid;
http_server {
    enabled         on;
    listen          8080;
    #dir             ./objs/nginx/html;
    dir  /home/srs4/trunk/research;
    https {
        enabled on;
        listen  80;
        key /home/key/xxx.xxx.com.key;
        cert /home/key/xxx.xxx.com.pem;
        
    }
}

http_api {
    enabled         on;
    listen          1986;
    crossdomain     on;
    https {
        enabled on;
        listen  1985;
        key /home/key/xxx.xxx.com.key;
        cert /home/key/xxx.xxx..com.pem;
    }
}

stats {
    network         0;
}

rtc_server {
    enabled on;
    # Listen at udp://8000
    listen 8000;
    #
    # The $CANDIDATE means fetch from env, if not configed, use * as default.
    #
    # The * means retrieving server IP automatically, from all network interfaces,
    # @see https://github.com/ossrs/srs/wiki/v4_CN_RTCWiki#config-candidate
    candidate 118.xxx.xxx.xxx;
}

vhost __defaultVhost__ {
    rtc {
        enabled     on;
        bframe      discard;
        stun_timeout  10;
        nack  on;
        rtmp_to_rtc on;
        # @see https://github.com/ossrs/srs/wiki/v4_CN_WebRTC#rtc-to-rtmp
        rtc_to_rtmp on;
    }
    http_remux {
        enabled     on;
        mount       [vhost]/[app]/[stream].flv;
    }
    hls {
        enabled         on;
        hls_path        /home/srs4/trunk/objs/nginx/html;
        hls_fragment    5;
        hls_window      30;
        hls_on_error    continue;
        hls_cleanup     on;
        hls_dispose      10;
    }
    #http_hooks {
        #enabled         on;
        #on_stop        https://xxx.xxx..com:8085/api/v1/streams/onStop;
    #}
}

Replay

How to replay bug?

Steps to reproduce the bug

Docker startup command

docker start command
sudo docker run -it -p 2000:1935 -p 2001:1986 -p 2002:8000/udp -p 2003:1985 -p 2004:8080 -p 2005:80 -v /home/key:/home/key -v /home/srs4:/home/srs4 ossrs/srs:4 objs/srs -c /home/srs4/trunk/conf/rtc.conf

Note:

  1. The UDP port 2002 mapped by Docker has been opened and set to UDP.
  2. The project in the /home/srs4 folder has been compiled locally. After starting it with the command, WebRTC can be played.

Playback method

Screenshot_20220209173506

nginx configuration
Screenshot_20220209173945

Expected Behavior (Expect)
WebRTC plays normally.

TRANS_BY_GPT3

@winlinvip
Copy link
Member

winlinvip commented Feb 10, 2022

Currently, Docker does not support changing the port because the address returned by SDP is still UDP/8000, not the UDP/2002 you specified.

Workaround method:

  1. You need to change the 8000 in the configuration file as well, because SRS is not aware that you are using 2002, so the returned SDP will not be 2002 either.
  2. You can specify 2002 during playback, for example: webrtc://xxx?eip=xxx:2002.

A better solution is to set the port through environment variables or specify the port in the CANDIDATE.

TRANS_BY_GPT3

@winlinvip winlinvip changed the title docker部署srs 无法播放WebRtc WebRTC: docker映射端口时,换成其他端口会失败,不支持环境变量设置端口 Feb 10, 2022
@winlinvip winlinvip changed the title WebRTC: docker映射端口时,换成其他端口会失败,不支持环境变量设置端口 WebRTC: docker映射端口时,换成其他端口会失败 Feb 10, 2022
@winlinvip winlinvip self-assigned this Feb 10, 2022
@winlinvip winlinvip added Bug It might be a bug. WebRTC WebRTC, RTC2RTMP or RTMP2RTC. labels Feb 10, 2022
@winlinvip winlinvip added this to the 5.0 milestone Feb 10, 2022
@LUOQING1994
Copy link
Author

LUOQING1994 commented Feb 10, 2022

Currently, Docker does not support changing the port because the address returned by SDP is still UDP/8000, not the UDP/2002 you specified.

Workaround method:

  1. You need to change the 8000 in the configuration file as well, because SRS doesn't know that you are using 2002, so the returned SDP won't be 2002 either.
  2. You can specify 2002 during playback, for example: webrtc://xxx?eip=xxx:2002.

A better solution is to set the port through environment variables or specify the port in the CANDIDATE.

Thank you very much! It's been resolved! I'm becoming more familiar with SRS ✌

TRANS_BY_GPT3

@winlinvip
Copy link
Member

winlinvip commented Feb 10, 2022

This one should not be closed, it can be improved. It needs to support port mapping without changing the configuration. Changing the configuration file is a bit troublesome, especially when multiple dockers need to be started.

TRANS_BY_GPT3

@winlinvip winlinvip reopened this Feb 10, 2022
@LUOQING1994
Copy link
Author

LUOQING1994 commented Feb 10, 2022

Don't close this, it can be improved. It can support port mapping without changing the configuration. Changing the configuration file is still a bit troublesome, especially when you have to start multiple dockers.

Okay, got it.

TRANS_BY_GPT3

@winlinvip winlinvip changed the title WebRTC: docker映射端口时,换成其他端口会失败 RTC: docker映射端口时,换成其他端口会失败 Jan 2, 2023
@winlinvip
Copy link
Member

Fixed in SRS 5, set listen port by environment variables.

@winlinvip winlinvip changed the title RTC: docker映射端口时,换成其他端口会失败 RTC: When mapping ports in Docker, changing to other ports will fail. Jul 28, 2023
@winlinvip winlinvip added the TransByAI Translated by AI/GPT. label Jul 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug It might be a bug. TransByAI Translated by AI/GPT. WebRTC WebRTC, RTC2RTMP or RTMP2RTC.
Projects
None yet
Development

No branches or pull requests

2 participants