SRS配置https拉流服务拉流失败,仅能拉取http拉流,看日志是握手问题
2025-09-21 23:32:01.32947774 Process: cpu=9.00%,210MB, threads=2
2025-09-21 23:32:02.71147774 HTTP #0 192.168.0.2:56630 GET http://192.168.0.202:9161/live/livestream.flv, content-length=-1
2025-09-21 23:32:02.71247774 dispatch cached gop success. count=138, duration=2028
2025-09-21 23:32:02.71247774 create consumer, active=1, queue_size=30000ms, jitter=1
2025-09-21 23:32:02.71247774 FLV /live/livestream.flv, encoder=FLV, mw_sleep=350ms, cache=0, msgs=128, dinm=1, guess_av=1/1/1
2025-09-21 23:32:02.71347774 FLV: write header audio=1, video=1, dinm=1, config=1/1/1
2025-09-21 23:32:03.06947774 -> HTS http: got 23 msgs, age=353110, min=8, mw=350
2025-09-21 23:32:03.12847774 HTTP #0 192.168.0.2:56631 GET http://192.168.0.202:9161/favicon.ico, content-length=-1
2025-09-21 23:32:03.12847774 http match file=./objs/nginx/html/favicon.ico, pattern=/, upath=/favicon.ico
2025-09-21 23:32:03.13447774 TCP: before dispose resource(HttpConn)(0x50700016e780), conns=3, zombies=0, ign=0, inz=0, ind=0
2025-09-21 23:32:03.13447774[104] client disconnect peer. ret=1007
2025-09-21 23:32:03.13447774 TCP: clear zombies=1 resources, conns=3, removing=0, unsubs=0
2025-09-21 23:32:03.13447774 TCP: disposing #0 resource(HttpConn)(0x50700016e780), conns=3, disposing=1, zombies=0
2025-09-21 23:32:03.72047774 <- CPB time=165018235, okbps=0,0,0, ikbps=0,1335,0, mr=0/350, p1stpt=20000, pnt=5000
2025-09-21 23:32:04.19247774 -> HLS time=170569565ms, sno=16, ts=livestream-15.ts, dur=3499ms, dva=0p
2025-09-21 23:32:06.08347774 Hybrid cpu=5.00%,216MB, cid=27,12, timer=61,0,0, clock=0,28,19,1,1,1,1,0,0, free=1, objs=(pkt:0,raw:0,fua:0,msg:221,oth:0,buf:0)
2025-09-21 23:32:06.33747774 Process: cpu=5.00%,217MB, threads=2
2025-09-21 23:32:11.08447774 Hybrid cpu=10.01%,223MB, cid=27,12, timer=61,0,0, clock=0,28,19,1,1,1,1,0,0, free=1, objs=(pkt:0,raw:0,fua:0,msg:221,oth:0,buf:0)
2025-09-21 23:32:11.34447774 Process: cpu=11.00%,225MB, threads=2
2025-09-21 23:32:12.21547774 TCP: before dispose resource(HttpsConn)(0x507000180300), conns=3, zombies=0, ign=0, inz=0, ind=0
2025-09-21 23:32:12.21547774[0] serve error code=4042(HttpsHandshake)(Failed to do handshake for HTTPS) : start : handshake : handshake r0=-1, r1=1
thread 47774: do_cycle() ./src/app/srs_app_http_conn.cpp:155
thread 47774: on_start() ./src/app/srs_app_http_conn.cpp:388
thread 47774: handshake() ./src/app/srs_app_conn.cpp:849
2025-09-21 23:32:12.21547774 TCP: clear zombies=1 resources, conns=3, removing=0, unsubs=0
2025-09-21 23:32:12.21547774 TCP: disposing #0 resource(HttpsConn)(0x507000180300), conns=3, disposing=1, zombies=0
2025-09-21 23:32:12.54147774 TCP: before dispose resource(HttpConn)(0x50700016d830), conns=2, zombies=0, ign=0, inz=0, ind=0
2025-09-21 23:32:12.54147774[11] client disconnect peer. ret=1007
使用环境:
--OS :Ubuntu 22.04
--SRS : 5.0 Stable
--push tool: FFmpeg
配置信息如下:
http server access entrance
http_server {
enabled on;
listen 9161; #8080
dir ./objs/nginx/html;
crossdomain on;
# to enable https
https {
enabled on;
listen 19161;
ssl_protocols TLSv1.2 TLSv1.3;
key ./conf/myserver1.key;
cert ./conf/myserver1.crt;
}}
- 使用CA证书失败, 使用OPENSSL自签证书尝试也是失败;
- 去掉 ssl_protocols 也无用
- 按官网的方式生成证书一一样
- 直接创建https服务会报内存溢出,只能放在http_server段落内
官方的https配置就那一点内容,估计证书的问题概率大吧
验证一下md5值是否一致,不一致的话就是key和cert不匹配;
再考虑一下防火墙上有没有其他限制,https端口开没开