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.32k stars 5.33k forks source link

Got "serve error code=2031 : rtmp handshake : complex handshake" when play the stream by RTMP #3557

Closed reallyimeric closed 1 year ago

reallyimeric commented 1 year ago

Note: Please read FAQ before file an issue, see #2716

Description

Player failed to play the stream with error on srs log serve error code=2031 : rtmp handshake : complex handshake : create s1 from c1 : dh init : init : dh generate key

I'm using openssl 3.0.8

  1. SRS Version: 4.0_r4

  2. SRS Log:

[2023-05-28 11:35:27.898][Trace][955892][0767o715] RTMP client ip=192.168.1.2:12345, fd=8
[2023-05-28 11:35:27.899][Trace][955892][0767o715] TCP: before dispose resource(RtmpConn)(0x55a9942b2350), conns=1, zombies=0, ign=0, inz=0, ind=0
[2023-05-28 11:35:27.899][Error][955892][0767o715][11] serve error code=2031 : rtmp handshake : complex handshake : create s1 from c1 : dh init : init : dh generate key
thread [955892][0767o715]: do_cycle() [src/app/srs_app_rtmp_conn.cpp:167][errno=11]
thread [955892][0767o715]: handshake() [src/protocol/srs_rtmp_stack.cpp:2283][errno=11]
thread [955892][0767o715]: handshake_with_client() [src/protocol/srs_rtmp_handshake.cpp:1198][errno=11]
thread [955892][0767o715]: s1_create() [src/protocol/srs_rtmp_handshake.cpp:570][errno=11]
thread [955892][0767o715]: initialize() [src/protocol/srs_rtmp_handshake.cpp:221][errno=11]
thread [955892][0767o715]: do_initialize() [src/protocol/srs_rtmp_handshake.cpp:336][errno=11](Resource temporarily unavailable)
[2023-05-28 11:35:27.899][Trace][955892][741618f0] TCP: clear zombies=1 resources, conns=1, removing=0, unsubs=0
[2023-05-28 11:35:27.899][Trace][955892][0767o715] TCP: disposing #0 resource(RtmpConn)(0x55a9942b2350), conns=1, disposing=1, zombies=0
  1. SRS Config:
# the config for srs to delivery realtime RTMP stream
# @see https://github.com/ossrs/srs/wiki/v2_CN_SampleRealtime
# @see full.conf for detail config.

listen              1935;
max_connections     1000;
daemon              off;
srs_log_tank        console;
#pid                 /run/srs.pid
vhost __defaultVhost__ {
    tcp_nodelay     on
    min_latency     on;

    play {
        gop_cache       off;
        queue_length    10;
        mw_latency      100;
    }

    publish {
        mr off;
    }
}

Replay

Please describe how to replay the bug?

Step 1: push to rtmp stream using OBS with AMD HW h.264 encoding

push to srs using OBS GUI

Step 2: watch the stream using MPC-HC or mpv

open url rtmp://xxxx/xxxx/xxxx in the player

Expect

Please describe your expectation.

Live stream shows on the player

Actual results

Failed to play and error on srs log (see above)

winlinvip commented 1 year ago

The "dh generate key" error is produced by OpenSSL. Is this a randomly occurring bug, or is there a consistent and reliable method to reproduce it? Could you help to test SRS 5.0, as it utilizes a newer version of OpenSSL that might exhibit different behavior?

reallyimeric commented 1 year ago

The "dh generate key" error is produced by OpenSSL. Is this a randomly occurring bug, or is there a consistent and reliable method to reproduce it? Could you help to test SRS 5.0, as it utilizes a newer version of OpenSSL that might exhibit different behavior?

I can always reproduce the issue, not occasionally. I'll try 5.0.

reallyimeric commented 1 year ago

Built tag v5.0-b1 with --generic-linux=on --srt=off. openssl version is 3.1.1.

I can confirm it works normally

[2023-06-11 18:26:51.968][INFO][22331][m58zi67c] RTMP client ip=127.0.0.1:42838, fd=10
[2023-06-11 18:26:51.969][INFO][22331][m58zi67c] complex handshake success
[2023-06-11 18:26:52.014][INFO][22331][m58zi67c] connect app, tcUrl=rtmp://localhost:1935/live, pageUrl=, swfUrl=, schema=rtmp, vhost=localhost, port=1935, app=live, args=null
[2023-06-11 18:26:52.014][INFO][22331][m58zi67c] protocol in.buffer=0, in.ack=0, out.ack=0, in.chunk=128, out.chunk=128
[2023-06-11 18:26:52.104][INFO][22331][m58zi67c] ignore AMF0/AMF3 command message.
[2023-06-11 18:26:52.151][INFO][22331][m58zi67c] ignore AMF0/AMF3 command message.
[2023-06-11 18:26:52.151][INFO][22331][m58zi67c] client identified, type=rtmp-play, vhost=localhost, app=live, stream=test, param=, duration=-1ms
[2023-06-11 18:26:52.151][INFO][22331][m58zi67c] connected stream, tcUrl=rtmp://localhost:1935/live, pageUrl=, swfUrl=, schema=rtmp, vhost=__defaultVhost__, port=1935, app=live, stream=test, param=, args=null
[2023-06-11 18:26:52.151][INFO][22331][m58zi67c] source url=/live/test, ip=127.0.0.1, cache=0/2500, is_edge=0, source_id=a2v4d612/a2v4d612
[2023-06-11 18:26:52.151][INFO][22331][m58zi67c] set fd=10 TCP_NODELAY 0=>1
[2023-06-11 18:26:52.151][INFO][22331][m58zi67c] dispatch cached gop success. count=0, duration=0
[2023-06-11 18:26:52.151][INFO][22331][m58zi67c] create consumer, active=1, queue_size=0.00, jitter=10000000
[2023-06-11 18:26:52.151][INFO][22331][m58zi67c] set fd=10, SO_SNDBUF=2626560=>50000, buffer=100ms
[2023-06-11 18:26:52.151][INFO][22331][m58zi67c] start play smi=0ms, mw_sleep=100, mw_msgs=8, realtime=0, tcp_nodelay=1