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.37k stars 5.34k forks source link

Unable to run due to maximum connection limit adjustment. #1499

Closed pktongyi1 closed 3 years ago

pktongyi1 commented 4 years ago

Description Describe the problem you encountered. Under CentOS 7, when using the command "vim /etc/security/limits.conf", append to the end of the file.

[2019-11-25 16:18:00.059][Trace][8693][0] SRS/3.0.60(OuXuli) [2019-11-25 16:18:00.060][Trace][8693][0] license: The MIT License (MIT) [2019-11-25 16:18:00.060][Trace][8693][0] contributors: winlinwinlin@vip.126.com wenjie.zhao740936897@qq.com xiangcheng.liuliuxc0116@foxmail.com naijia.liuyoungcow@youngcow.net alcoholyialcoholyi@qq.com bytemanwangchen2011@gmail.com chad.wangchad.wang.cn@gmail.com suhetaosuhetao@gmail.com Johnnyfengjihu@163.com karthikeyankeyanmca@gmail.com StevenLiulq@chinaffmpeg.org zhengflzhengfl_1989@126.com tufang14breadbean1449@gmail.com allspaceallspace@gmail.com niesongsongnie950@gmail.com rudeb0tnimrod@themanxgroup.tw CallMeNPnp.liamg@gmail.com synotesynote@qq.com lovecatlittlefawn@163.com panda1986542638787@qq.com YueHonghuihongf.yue@hotmail.com ThomasDreibholzdreibh@simula.no JuntaoLiujuntliu@gmail.com RocFangfangpeng1986@gmail.com MakarovYaroslavyaroslav.makarov.97@mail.ru MirkoVelicmvelic@inoxx.net HuiZhang(huzhang2)huzhang2@cisco.com OtterWasimpleotter23@gmail.com walkermi172192667@qq.com haofzfuzhuang.hao@vhall.com ME_Kun_Hanhanvskun@hotmail.com ljx0305ljx0305@gmail.com cenxinweicenshanhe@163.com StarBrilliantm13253@hotmail.com xubinxubin@chnvideo.com intliangyintiliang@gmail.com flowerwrongsysuyangkang@gmail.com [2019-11-25 16:18:00.060][Trace][8693][0] build: 2019-10-07 20:27:10, configure: --x86-x64 --prefix=/usr/local/srs, uname: Linux centos7 3.10.0-327.3.1.el7.x86_64 #1 SMP Wed Dec 9 14:09:15 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux [2019-11-25 16:18:00.060][Trace][8693][0] configure detail: --prefix=/usr/local/srs --with-hls --with-hds --with-dvr --without-nginx --with-ssl --without-ffmpeg --with-transcode --with-ingest --with-stat --with-http-callback --with-http-server --with-stream-caster --with-http-api --with-librtmp --without-research --with-utest --without-gperf --without-gmc --without-gmd --without-gmp --without-gcp --without-gprof --without-arm-ubuntu12 --without-mips-ubuntu12 --log-trace [2019-11-25 16:18:00.060][Trace][8693][0] cwd=/root/Desktop/SRS-CentOS7-x86_64-3.0.60/usr/local/srs, work_dir=./ [2019-11-25 16:18:00.060][Trace][8693][0] srs checking config... [2019-11-25 16:18:00.061][Trace][8693][0] ips, iface[0] ens33 ipv4 0x11043 10.108.3.250, iface[1] ens33 ipv6 0x11043 fe80::77c6:665b:c328:ddd91.709418e-316ns33 [2019-11-25 16:18:00.061][Trace][8693][0] devices, intranet ens33 10.108.3.250, intranet ens33 fe80::77c6:665b:c328:ddd91.709418e-316ns33 [2019-11-25 16:18:00.061][Warn][8693][0][2] stats network use index=0, ip=10.108.3.250 [2019-11-25 16:18:00.061][Warn][8693][0][2] stats disk list: sda sdb xvda xvdb [2019-11-25 16:18:00.061][Trace][8693][0] write log to file ./objs/srs.log [2019-11-25 16:18:00.061][Trace][8693][0] you can: tailf ./objs/srs.log [2019-11-25 16:18:00.061][Trace][8693][0] @see: https://github.com/ossrs/srs/wiki/v1_CN_SrsLog [2019-11-25 16:18:00.061][Error][8693][0][2] invalid max_connections=5000, required=5107, system limit to 1024, total=5007(max_connections=5000, nb_consumed_fds=7). you can change max_connections from 5000 to 1016, or you can login as root and set the limit: ulimit -HSn 5107(No such file or directory) [2019-11-25 16:18:00.061][Error][8693][0][2] Failed, code=1023 : check config : check connections : 5007 exceed max open files=1024 thread #0: do_main() [src/main/srs_main_server.cpp:175][errno=2] thread #0: check_config() [src/app/srs_app_config.cpp:3470][errno=2] thread #0: check_number_connections() [src/app/srs_app_config.cpp:3919][errno=2](No such file or directory)

Reproduction The steps to reproduce the bug are as follows:

  1. Change max_connections from 1000 to max_connections 5000.
  2. Run 'sudo bash INSTALL'.
  3. Run 'sudo systemctl start srs'.
  4. The bug is reproduced, and the key information is as follows: [2019-11-25 16:18:00.059][Trace][8693][0] SRS/3.0.60(OuXuli) [2019-11-25 16:18:00.060][Trace][8693][0] license: The MIT License (MIT) [2019-11-25 16:18:00.060][Trace][8693][0] contributors: winlinwinlin@vip.126.com wenjie.zhao740936897@qq.com xiangcheng.liuliuxc0116@foxmail.com naijia.liuyoungcow@youngcow.net alcoholyialcoholyi@qq.com bytemanwangchen2011@gmail.com chad.wangchad.wang.cn@gmail.com suhetaosuhetao@gmail.com Johnnyfengjihu@163.com karthikeyankeyanmca@gmail.com StevenLiulq@chinaffmpeg.org zhengflzhengfl_1989@126.com tufang14breadbean1449@gmail.com allspaceallspace@gmail.com niesongsongnie950@gmail.com rudeb0tnimrod@themanxgroup.tw CallMeNPnp.liamg@gmail.com synotesynote@qq.com lovecatlittlefawn@163.com panda1986542638787@qq.com YueHonghuihongf.yue@hotmail.com ThomasDreibholzdreibh@simula.no JuntaoLiujuntliu@gmail.com RocFangfangpeng1986@gmail.com MakarovYaroslavyaroslav.makarov.97@mail.ru MirkoVelicmvelic@inoxx.net HuiZhang(huzhang2)huzhang2@cisco.com OtterWasimpleotter23@gmail.com walkermi172192667@qq.com haofzfuzhuang.hao@vhall.com ME_Kun_Hanhanvskun@hotmail.com ljx0305ljx0305@gmail.com cenxinweicenshanhe@163.com StarBrilliantm13253@hotmail.com xubinxubin@chnvideo.com intliangyintiliang@gmail.com flowerwrongsysuyangkang@gmail.com [2019-11-25 16:18:00.060][Trace][8693][0] build: 2019-10-07 20:27:10, configure: --x86-x64 --prefix=/usr/local/srs, uname: Linux centos7 3.10.0-327.3.1.el7.x86_64 #1 SMP Wed Dec 9 14:09:15 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux [2019-11-25 16:18:00.060][Trace][8693][0] configure detail: --prefix=/usr/local/srs --with-hls --with-hds --with-dvr --without-nginx --with-ssl --without-ffmpeg --with-transcode --with-ingest --with-stat --with-http-callback --with-http-server --with-stream-caster --with-http-api --with-librtmp --without-research --with-utest --without-gperf --without-gmc --without-gmd --without-gmp --without-gcp --without-gprof --without-arm-ubuntu12 --without-mips-ubuntu12 --log-trace [2019-11-25 16:18:00.060][Trace][8693][0] cwd=/root/Desktop/SRS-CentOS7-x86_64-3.0.60/usr/local/srs, work_dir=./ [2019-11-25 16:18:00.060][Trace][8693][0] srs checking config... [2019-11-25 16:18:00.061][Trace][8693][0] ips, iface[0] ens33 ipv4 0x11043 10.108.3.250, iface[1] ens33 ipv6 0x11043 fe80::77c6:665b:c328:ddd91.709418e-316ns33 [2019-11-25 16:18:00.061][Trace][8693][0] devices, intranet ens33 10.108.3.250, intranet ens33 fe80::77c6:665b:c328:ddd91.709418e-316ns33 [2019-11-25 16:18:00.061][Warn][8693][0][2] stats network use index=0, ip=10.108.3.250 [2019-11-25 16:18:00.061][Warn][8693][0][2] stats disk list: sda sdb xvda xvdb [2019-11-25 16:18:00.061][Trace][8693][0] write log to file ./objs/srs.log [2019-11-25 16:18:00.061][Trace][8693][0] you can: tailf ./objs/srs.log [2019-11-25 16:18:00.061][Trace][8693][0] @see: https://github.com/ossrs/srs/wiki/v1_CN_SrsLog [2019-11-25 16:18:00.061][Error][8693][0][2] invalid max_connections=5000, required=5107, system limit to 1024, total=5007(max_connections=5000, nb_consumed_fds=7). you can change max_connections from 5000 to 1016, or you can login as root and set the limit: ulimit -HSn 5107(No such file or directory) [2019-11-25 16:18:00.061][Error][8693][0][2] Failed, code=1023 : check config : check connections : 5007 exceed max open files=1024 thread #0: do_main() [src/main/srs_main_server.cpp:175][errno=2] thread #0: check_config() [src/app/srs_app_config.cpp:3470][errno=2] thread #0: check_number_connections() [src/app/srs_app_config.cpp:3919][errno=2](No such file or directory)

Expected behavior Fix this issue by adding the option to enable startup service.

TRANS_BY_GPT3

baiyu0820 commented 4 years ago

centos7 also encountered this issue. When modifying the max_connections value to be greater than 1024, as long as the system is not restarted, it can be used normally. However, after restarting, it is found that srs cannot start up properly and reports an error.

TRANS_BY_GPT3

winlinvip commented 3 years ago

Check it.

Freamerhxl commented 3 years ago

Ubuntu has the same problem.

TRANS_BY_GPT3

huzhou520 commented 3 years ago

I also encountered this issue. I added the SRS startup command to /etc/rc.local, but it resulted in an error when automatically starting up. However, I can manually start it after booting up.

TRANS_BY_GPT3

joysun2006 commented 3 years ago

Problem Cause: The official default compilation does not enable epoll and other modes in the st library, but instead uses the select mode. The maximum number of open sockets in this mode is 1024. Therefore, the maximum value of max open files is set to 1024 without limiting it according to the system's settings.

Solution: Run the command "./configure --extra-flags="-DMD_HAVE_EPOLL

TRANS_BY_GPT3

magic000 commented 3 years ago

I also encountered this problem, it reported an error, system limit to 1024, but my machine is actually not 1024.

TRANS_BY_GPT3

winlinvip commented 3 years ago

This is a system issue, guys. Please refer to the Linux manual.

TRANS_BY_GPT3

ximenpo commented 2 years ago

The reason for the maximum of 1024 is that the Makefile of st-srs checks whether the file /usr/include/sys/epoll.h exists. If it doesn't exist, the DMD_HAVE_EPOLL macro will not be added, and the default select method will be used. Since select only supports 1024, st-srs sets the setrlimit to 1024.

In the new Ubuntu system, the directory /usr/include/sys has been changed to /usr/include/i386-linux-gnu/sys or /usr/include/x86_64-linux-gnu/sys. This change can cause the mentioned issue. The solution is either to create a symbolic link or modify the Makefile of st-srs to make it compatible.

TRANS_BY_GPT3

acerest commented 2 years ago

Ubuntu 20.04 still has issues, and I haven't found a solution yet. Confirm that the system itself is not limited to 1024. Please take a look, thank you @winlinvip.

TRANS_BY_GPT3