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.48k stars 5.36k forks source link

Forward add question mark to the end and Erroneous C2 #3405

Closed jb-alvarado closed 1 year ago

jb-alvarado commented 1 year ago

Description

I use the backend API in the forward statement. Everything works fine, but srs adds a ? to the end of the URL. Is that desired?

In my case is a problem, because I forward to a ffmpeg instance, and there I monitor the logging output and cancel processing, when stream URL is not matching.

I get for example this output:

 [rtmp @ 0x559de648ed80] [warning] Unexpected stream my-test-stream?, expecting my-test-stream
 [rtmp @ 0x559de648ed80] Unexpected stream my-test-stream?, expecting my-test-stream

And there is a second issue in combination with ffmpeg, I get there this warnings:

[rtmp @ 0x7f2ed00015c0] Erroneous C2 Message epoch does not match up with C1 epoch
[rtmp @ 0x7f2ed00015c0] Erroneous C2 Message random does not match up
  1. SRS Version: 5.0.139

  2. SRS Config:

listen              1935 1936;
max_connections     200;
daemon              off;
pid                 /usr/local/srs/objs/srs.pid;
srs_log_tank        console; # file;
srs_log_file        /var/log/srs.log;
ff_log_dir          /dev/null;

# can be: verbose, info, trace, warn, error
srs_log_level       error;

vhost __defaultVhost__ {
    enabled             off;
}

vhost srs.example.org {
    enabled             on;

    publish {
        normal_timeout      20000;
    }

    play {
        time_jitter     full;
        mix_correct     on;
    }

    forward {
        enabled on;
        backend http://127.0.0.1:8085/api/v1/forward;
    }
}

Expect

About the Erroneous C2 ... warning, I don't know if they are harmful. About the question mark it would be nice, if there would be no extra characters on the given URL.

chundonglinlin commented 1 year ago

Can you give more detail information? For example, your publish stream command and SRS detail log. I cannot analyze your problem for info currently given. @jb-alvarado

jb-alvarado commented 1 year ago

I'm sorry @chundonglinlin, that I hadn't described the problem better! Yesterday after writing, I also took a closer look at the pull request for this function and realised that I might be using it differently than you had planed:

We have adapted the Go API a little so that it outputs different target URLs depending on the stream name. So the API reads in a JSON file with this format:

{
    "strict": true,
    "proxy": [
        {
            "stream": "test-stream1",
            "urls": [
                "rtmp://127.0.0.1:1936/live/stream1",
                "rtmp://127.0.0.1:1937/live/stream2"
            ]
        },
        {
            "stream": "test-stream2",
            "urls": [
                "rtmp://127.0.0.1:1938/live/stream3",
                "rtmp://127.0.0.1:1939/live/stream4"
            ]
        }
    ]
}

If desired, I can share the API code.

Now when a stream comes in, for example with the name rtmp://example.org/live/test-stream1, the API returns the corresponding URLs:

"urls": [
        "rtmp://127.0.0.1:1936/live/stream1",
        "rtmp://127.0.0.1:1937/live/stream2"
    ]

My streaming command to SRS looks something like this:

ffmpeg -re -i input.mp4 -c:v libx264 -crf 23 -preset ultrafast -f flv rtmp://127.0.0.1/live/test-stream1

Here is a full trace log, from SRS:

[2023-02-08 07:27:12.528][INFO][28110][41mk7240] XCORE-SRS/5.0.139(Bee)
[2023-02-08 07:27:12.528][INFO][28110][41mk7240] config parse complete
[2023-02-08 07:27:12.528][INFO][28110][41mk7240] write log to console
[2023-02-08 07:27:12.528][INFO][28110][41mk7240] SRS/5.0.139(Bee), MIT
[2023-02-08 07:27:12.528][INFO][28110][41mk7240] authors: Winlin<winlin@vip.126.com> ZhaoWenjie<zhaowenjie@tal.com> ShiWei<shiwei05@kuaishou.com> XiaoZhihong<hondaxiao@tencent.com> WuPengqiang<pengqiang.wpq@alibaba-inc.com> XiaLixin<xialixin@kanzhun.com> LiPeng<mozhan.lp@alibaba-inc.com> ChenGuanghua<jinxue.cgh@alibaba-inc.com> ChenHaibo<nmgchenhaibo@foxmail.com> and https://github.com/ossrs/srs/blob/develop/trunk/AUTHORS.md#contributors
[2023-02-08 07:27:12.528][INFO][28110][41mk7240] cwd=/home/jonathan/DEV/github/srs/trunk, work_dir=./, build: 2023-02-07 08:20:44, configure: --ffmpeg-fit=off --srt=off, uname: Linux jonathan-nix-lan-daswort-media 6.1.9-200.fc37.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Feb  2 00:21:48 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux, osx: 0, env: 0, pkg: 
[2023-02-08 07:27:12.528][INFO][28110][41mk7240] configure detail: --prefix=/usr/local/srs --config=conf/srs.conf --osx=off --hls=on --hds=off --dvr=on --ssl=on --https=on --ssl-1-0=off --ssl-local=off --sys-ssl=off --transcode=on --ingest=on --stat=on --http-callback=on --http-server=on --stream-converter=on --http-api=on --utest=off --cherrypy=off --srt=off --rtc=on --gb28181=off --simulator=off --cxx11=on --cxx14=off --backtrace=on --ffmpeg-fit=off --ffmpeg-opus=off --nasm=on --srtp-nasm=on --clean=on --gperf=off --gmc=off --gmd=off --gmp=off --gcp=off --gprof=off --static=off --shared-st=off --shared-srt=off --shared-ffmpeg=off --log-verbose=off --log-info=off --log-trace=on --log-level_v2=on --gcov=off --apm=off --debug=off --debug-stats=off --cross-build=off --sanitizer=off --sanitizer-static=off --sanitizer-log=off --cygwin64=off --single-thread=off --cc=gcc --cxx=g++ --ar=ar --ld=ld --randlib=randlib
[2023-02-08 07:27:12.528][INFO][28110][41mk7240] srs checking config...
[2023-02-08 07:27:12.528][INFO][28110][41mk7240] ips, iface[0] br0 ipv4 0x11043 10.10.0.40, iface[1] br0 ipv6 0x11043 fe80::3193:fa18:f987:74e7%br0, iface[2] vnet1 ipv6 0x11043 fe80::fc54:ff:fe89:37b4%vnet1
[2023-02-08 07:27:12.528][INFO][28110][41mk7240] devices, intranet br0 10.10.0.40, intranet br0 fe80::3193:fa18:f987:74e7%br0, intranet vnet1 fe80::fc54:ff:fe89:37b4%vnet1
[2023-02-08 07:27:12.528][WARN][28110][41mk7240][22] stats network use index=0, ip=10.10.0.40, ifname=br0
[2023-02-08 07:27:12.528][WARN][28110][41mk7240][22] stats disk not configed, disk iops disabled.
[2023-02-08 07:27:12.528][INFO][28110][41mk7240] write log to console
[2023-02-08 07:27:12.528][INFO][28110][41mk7240] features, rch:on, dash:on, hls:on, hds:off, srt:off, hc:on, ha:on, hs:on, hp:on, dvr:on, trans:on, inge:on, stat:on, sc:on
[2023-02-08 07:27:12.528][INFO][28110][41mk7240] SRS on amd64 x86_64, conf:conf/forward.backend.conf, limit:1000, writev:1024, encoding:little-endian, HZ:100
[2023-02-08 07:27:12.528][INFO][28110][41mk7240] mw sleep:350ms. mr enabled:on, default:0, sleep:350ms
[2023-02-08 07:27:12.528][INFO][28110][41mk7240] gc:on, pq:30000ms, cscc:[0,16), csa:on, tn:on(may hurts performance), ss:auto(guess by merged write)
[2023-02-08 07:27:12.528][INFO][28110][41mk7240] system default latency(ms): mw(0-350) + mr(0-350) + play-queue(0-30000)
[2023-02-08 07:27:12.528][WARN][28110][41mk7240][22] SRS/5.0.139 is not stable
[2023-02-08 07:27:12.528][INFO][28110][41mk7240] write pid=28110 to ./objs/srs.backend.pid success!
[2023-02-08 07:27:12.528][INFO][28110][41mk7240] Thread #1(primordial): init name=srs-master-1, interval=5000ms
[2023-02-08 07:27:12.528][INFO][28110][41mk7240] Pool: Start threads primordial=1, hybrids=1 ok
[2023-02-08 07:27:12.529][INFO][28110][64a9di6g] Thread #2: run with tid=28111, entry=0x2bf3180, label=hybrid, name=srs-hybrid-2
[2023-02-08 07:27:12.532][INFO][28110][64a9di6g] fingerprint=41:71:88:52:EB:34:64:EB:28:36:94:D1:22:54:94:9E:4F:11:7B:D8:7C:4F:13:2C:EA:3C:5F:6A:2A:60:50:03
[2023-02-08 07:27:12.532][INFO][28110][64a9di6g] CircuitBreaker: enabled=1, high=2x90, critical=1x95, dying=5x99
[2023-02-08 07:27:12.532][INFO][28110][64a9di6g] http: root mount to ./objs/nginx/html
[2023-02-08 07:27:12.532][INFO][28110][64a9di6g] server main cid=64a9di6g, pid=28110, ppid=21844, asprocess=0
[2023-02-08 07:27:12.532][INFO][28110][64a9di6g] RTMP listen at tcp://0.0.0.0:1935, fd=8
[2023-02-08 07:27:12.532][INFO][28110][64a9di6g] signal installed, reload=1, reopen=10, fast_quit=15, grace_quit=3
[2023-02-08 07:27:12.532][INFO][28110][64a9di6g] http: api mount /console to ./objs/nginx/html/console
[2023-02-08 07:27:12.532][INFO][28110][5e0003f3] Hybrid cpu=0.00%,16MB
[2023-02-08 07:27:12.532][WARN][28110][15380459][22] use private address as ip: 10.10.0.40, ifname=br0
[2023-02-08 07:27:12.532][INFO][28110][15380459] Startup query id=vid-436866n, session=vid-32m9ovq, eip=10.10.0.40, wait=300s
[2023-02-08 07:27:12.532][INFO][28110][599a2m4d] TCP: connection manager run, conns=0
[2023-02-08 07:27:12.532][INFO][28110][6iqdl565] RTC: connection manager run, conns=0
[2023-02-08 07:27:17.529][INFO][28110][5e0003f3] Hybrid cpu=0.00%,16MB
[2023-02-08 07:27:17.534][INFO][28110][41mk7240] Process: cpu=1.00%,16MB, threads=2
[2023-02-08 07:27:22.530][INFO][28110][5e0003f3] Hybrid cpu=0.00%,16MB
[2023-02-08 07:27:22.539][INFO][28110][41mk7240] Process: cpu=0.00%,16MB, threads=2
[2023-02-08 07:27:23.997][INFO][28110][52o5pky0] RTMP client ip=127.0.0.1:44734, fd=9
[2023-02-08 07:27:23.998][INFO][28110][52o5pky0] complex handshake success
[2023-02-08 07:27:24.039][INFO][28110][52o5pky0] connect app, tcUrl=rtmp://127.0.0.1:1935/live, pageUrl=, swfUrl=, schema=rtmp, vhost=127.0.0.1, port=1935, app=live, args=null
[2023-02-08 07:27:24.039][INFO][28110][52o5pky0] protocol in.buffer=0, in.ack=0, out.ack=0, in.chunk=128, out.chunk=128
[2023-02-08 07:27:24.121][INFO][28110][52o5pky0] client identified, type=fmle-publish, vhost=127.0.0.1, app=live, stream=test-stream1, param=, duration=0ms
[2023-02-08 07:27:24.121][INFO][28110][52o5pky0] connected stream, tcUrl=rtmp://127.0.0.1:1935/live, pageUrl=, swfUrl=, schema=rtmp, vhost=__defaultVhost__, port=1935, app=live, stream=test-stream1, param=, args=null
[2023-02-08 07:27:24.121][INFO][28110][52o5pky0] new live source, stream_url=/live/test-stream1
[2023-02-08 07:27:24.121][INFO][28110][52o5pky0] source url=/live/test-stream1, ip=127.0.0.1, cache=1/2500, is_edge=0, source_id=/
[2023-02-08 07:27:24.204][INFO][28110][52o5pky0] http: on_forward_backend ok, client_id=52o5pky0, url=http://127.0.0.1:8085/api/v1/forward, request={"action":"on_forward","server_id":"vid-436866n","client_id":"52o5pky0","ip":"127.0.0.1","vhost":"__defaultVhost__","app":"live","tcUrl":"rtmp://127.0.0.1:1935/live","stream":"test-stream1","param":""}, response={"code":0,"data":{"urls":["rtmp://127.0.0.1:1936/live/stream1","rtmp://127.0.0.1:1937/live/stream2"]}}
[2023-02-08 07:27:24.205][INFO][28110][52o5pky0] ignore disabled exec for vhost=__defaultVhost__
[2023-02-08 07:27:24.205][INFO][28110][52o5pky0] start publish mr=0/350, p1stpt=20000, pnt=5000, tcp_nodelay=0
[2023-02-08 07:27:24.205][INFO][28110][11i67vr1] Forwarder: Start forward 127.0.0.1/live/stream1 of source=[52o5pky0] to 127.0.0.1:1936
[2023-02-08 07:27:24.206][INFO][28110][9kaw86vf] Forwarder: Start forward 127.0.0.1/live/stream2 of source=[52o5pky0] to 127.0.0.1:1937
[2023-02-08 07:27:24.212][INFO][28110][11i67vr1] complex handshake success.
[2023-02-08 07:27:24.212][INFO][28110][11i67vr1] protocol in.buffer=0, in.ack=0, out.ack=0, in.chunk=128, out.chunk=128
[2023-02-08 07:27:24.213][INFO][28110][9kaw86vf] complex handshake success.
[2023-02-08 07:27:24.213][INFO][28110][9kaw86vf] protocol in.buffer=0, in.ack=0, out.ack=0, in.chunk=128, out.chunk=128
[2023-02-08 07:27:24.295][INFO][28110][11i67vr1] connected, version=0.0.0.0, ip=, pid=0, id=0, dsu=1
[2023-02-08 07:27:24.296][INFO][28110][9kaw86vf] connected, version=0.0.0.0, ip=, pid=0, id=0, dsu=1
[2023-02-08 07:27:24.732][INFO][28110][52o5pky0] got metadata, width=1920, height=1080, vcodec=7, acodec=2
[2023-02-08 07:27:25.873][INFO][28110][52o5pky0] 45B video sh,  codec(7, profile=Baseline, level=4, 1920x1080, 0kbps, 0.0fps, 0.0s)
[2023-02-08 07:27:25.873][INFO][28110][52o5pky0] 385B audio sh, codec(2, 16bits, 2channels, 44100HZ)
[2023-02-08 07:27:27.530][INFO][28110][5e0003f3] Hybrid cpu=0.00%,16MB, cid=7,1, timer=62,0,0, clock=0,48,1,0,0,0,0,0,0, objs=(pkt:0,raw:0,fua:0,msg:39,oth:0,buf:0)
[2023-02-08 07:27:27.544][INFO][28110][41mk7240] Process: cpu=1.00%,17MB, threads=2
[2023-02-08 07:27:31.052][WARN][28110][11i67vr1][4] Forwarder: Ignore error, code=1007(SocketRead)(Socket read data failed) : forward : receive control message : recv interlaced message : read basic header : basic header requires 1 bytes : read bytes : read
thread [28110][11i67vr1]: do_cycle() [./src/app/srs_app_forward.cpp:235][errno=4]
thread [28110][11i67vr1]: forward() [./src/app/srs_app_forward.cpp:281][errno=4]
thread [28110][11i67vr1]: recv_message() [./src/protocol/srs_protocol_rtmp_stack.cpp:341][errno=4]
thread [28110][11i67vr1]: recv_interlaced_message() [./src/protocol/srs_protocol_rtmp_stack.cpp:792][errno=4]
thread [28110][11i67vr1]: read_basic_header() [./src/protocol/srs_protocol_rtmp_stack.cpp:887][errno=4]
thread [28110][11i67vr1]: grow() [./src/protocol/srs_protocol_stream.cpp:162][errno=4]
thread [28110][11i67vr1]: read() [./src/protocol/srs_protocol_st.cpp:566][errno=4]
[2023-02-08 07:27:31.052][WARN][28110][9kaw86vf][4] Forwarder: Ignore error, code=1007(SocketRead)(Socket read data failed) : forward : receive control message : recv interlaced message : read basic header : basic header requires 1 bytes : read bytes : read
thread [28110][9kaw86vf]: do_cycle() [./src/app/srs_app_forward.cpp:235][errno=4]
thread [28110][9kaw86vf]: forward() [./src/app/srs_app_forward.cpp:281][errno=4]
thread [28110][9kaw86vf]: recv_message() [./src/protocol/srs_protocol_rtmp_stack.cpp:341][errno=4]
thread [28110][9kaw86vf]: recv_interlaced_message() [./src/protocol/srs_protocol_rtmp_stack.cpp:792][errno=4]
thread [28110][9kaw86vf]: read_basic_header() [./src/protocol/srs_protocol_rtmp_stack.cpp:887][errno=4]
thread [28110][9kaw86vf]: grow() [./src/protocol/srs_protocol_stream.cpp:162][errno=4]
thread [28110][9kaw86vf]: read() [./src/protocol/srs_protocol_st.cpp:566][errno=4]
[2023-02-08 07:27:31.052][INFO][28110][52o5pky0] cleanup when unpublish
[2023-02-08 07:27:31.052][INFO][28110][52o5pky0] TCP: before dispose resource(RtmpConn)(0x7fada40318f0), conns=1, zombies=0, ign=0, inz=0, ind=0
[2023-02-08 07:27:31.052][WARN][28110][52o5pky0][4] client disconnect peer. ret=1009
[2023-02-08 07:27:31.052][INFO][28110][599a2m4d] TCP: clear zombies=1 resources, conns=1, removing=0, unsubs=0
[2023-02-08 07:27:31.052][INFO][28110][52o5pky0] TCP: disposing #0 resource(RtmpConn)(0x7fada40318f0), conns=1, disposing=1, zombies=0
[2023-02-08 07:27:32.531][INFO][28110][5e0003f3] Hybrid cpu=1.00%,20MB, cid=7,1, timer=62,0,0, clock=0,48,1,0,0,0,0,0,0, objs=(pkt:0,raw:0,fua:0,msg:39,oth:0,buf:0)
[2023-02-08 07:27:32.549][INFO][28110][41mk7240] Process: cpu=1.00%,20MB, threads=2
^C[2023-02-08 07:27:32.573][INFO][28110][64a9di6g] sig=2, user terminate program, fast quit
[2023-02-08 07:27:33.541][INFO][28110][64a9di6g] cleanup for quit signal fast=1, grace=0
[2023-02-08 07:27:33.549][INFO][28110][41mk7240] quit for thread #2(hybrid) finished

Maybe SRS expects a URL to be specified as a query parameter, but since I don't specify any query parameters, the question mark is appended without any other parameters? Here it would be good if the question mark only appears if a query really follows.

It is also strange that there is no question mark in the trace log. But it does on the receiver side:

[rtmp @ 0x7ffb280015c0] Unexpected stream stream1?, expecting stream1
chundonglinlin commented 1 year ago

Can you give destination server log? I found SRS print backend's response right, its forwarders no problem, but you receive socket read error.

jb-alvarado commented 1 year ago

I guess you mean a second SRS server as destination? Normally my destination will be a ffmpeg instance in listening mode, but I have change it to a second srs instance to get a trace log:

[2023-02-08 15:50:44.519][Trace][325016][r0e6246z] RTMP client ip=10.20.0.30:44084, fd=16
[2023-02-08 15:50:44.528][Trace][325016][5xk8ai3a] Hybrid cpu=1.00%,14MB
[2023-02-08 15:50:44.554][Trace][325016][r0e6246z] complex handshake success
[2023-02-08 15:50:44.555][Trace][325016][r0e6246z] connect app, tcUrl=rtmp://example.org/live, pageUrl=, swfUrl=, schema=rtmp, vhost=example.org, port=1935, app=live, args=(obj)
[2023-02-08 15:50:44.555][Trace][325016][r0e6246z] edge-srs ip=10.20.0.30, version=5.0.139, pid=8014, id=0
[2023-02-08 15:50:44.555][Trace][325016][r0e6246z] protocol in.buffer=0, in.ack=0, out.ack=0, in.chunk=128, out.chunk=128
[2023-02-08 15:50:44.603][Trace][325016][r0e6246z] client identified, type=flash-publish, vhost=example.org, app=live, stream=stream1, param=?, duration=0ms
[2023-02-08 15:50:44.603][Trace][325016][r0e6246z] connected stream, tcUrl=rtmp://example.org/live, pageUrl=, swfUrl=, schema=rtmp, vhost=example.org, port=1935, app=live, stream=stream1, param=?, args=(obj)
[2023-02-08 15:50:44.603][Trace][325016][r0e6246z] new source, stream_url=example.org/live/stream1
[2023-02-08 15:50:44.603][Trace][325016][r0e6246z] source url=example.org/live/stream1, ip=10.20.0.30, cache=1, is_edge=0, source_id=/
[2023-02-08 15:50:44.603][Trace][325016][r0e6246z] ignore the disabled transcode: live/stream1
[2023-02-08 15:50:44.603][Trace][325016][r0e6246z] ignore disabled exec for vhost=example.org
[2023-02-08 15:50:44.603][Trace][325016][r0e6246z] start publish mr=0/350, p1stpt=20000, pnt=30000, tcp_nodelay=0
[2023-02-08 15:50:45.605][Trace][325016][r0e6246z] got metadata, width=1920, height=1080, vcodec=7, acodec=2
[2023-02-08 15:50:46.606][Trace][325016][r0e6246z] 45B video sh,  codec(7, profile=Baseline, level=4, 1920x1080, 0kbps, 0.0fps, 0.0s)

Interestingly here everything looks good, only param has a question mark. So maybe when streams a forwarded to ffmpeg, ffmpeg will transform the param as url query?

I think the socket read error can be ignore, it looks like they only show up when the connection is close.

chundonglinlin commented 1 year ago

Yes, you should show a second server logs, likely a second SRS server or other streaming server as destination. But how can you run ffmpeg as a rtmp streaming server? ffserver? You can show your ffmpeg command as server, I test again for your problem.

chundonglinlin commented 1 year ago

And I think you can configure forward to destination by comparing destination config with backend config. According to your error logs, you maybe get the same problem.

forward.master.conf

vhost __defaultVhost__ {
    forward {
        enabled on;
        destination 127.0.0.1:19350;
    }
}

forward.backend.conf

vhost __defaultVhost__ {
    forward {
        enabled on;
        backend http://127.0.0.1:8085/api/v1/forward;
    }
}
jb-alvarado commented 1 year ago

But how can you run ffmpeg as a rtmp streaming server?

Yes you can run ffmpeg in listening mode, so it can act as a server, like:

ffmpeg -f live_flv -listen 1 -i rtmp://0.0.0.0:1936/live/stream -c copy -f null -

I use this for ffplayout to get live ingest to work. And for simple authentication I monitor the logging output for Unexpected stream message, to cancel the process when the stream key don't match.

And I think you can configure forward to destination by comparing destination config with backend config. According to your error logs, you maybe get the same problem.

I have check this and with destination I don't get an question mark at the end, only in backend mode.

chundonglinlin commented 1 year ago

I test foward backend by your method, Interestingly here everything looks good,

Start command:

Make sure to maintain the markdown structure. image

Logs output:

Make sure to maintain the markdown structure. image

Here are my executive commands:

  1. SRS-backend: listen 1935
    ./objs/srs -c conf/forward.backend.conf
  2. SRS-slave: listen 29350
    ./objs/srs -c conf/forward.slave.conf
  3. backend-server: listen 8085
    6.0: go run server.go
    5.0: python ./server.py 8085
  4. ffmpeg: listen on port 19350, publish to SRS-slave on port 29350
    ffmpeg -f live_flv -listen 1 -i rtmp://0.0.0.0:19350/live/stream -c copy -f flv "rtmp://127.0.0.1:29350/test/teststream"
  5. ffmpeg publish:
    ffmpeg -re -i 264_aac.flv -c copy -f flv "rtmp://127.0.0.1/live/livestream"

    Lastly, do you think output errors should fix it?

    [rtmp @ 0x5595cebeff80] Erroneous C2 Message epoch does not match up with C1 epoch
    [rtmp @ 0x5595cebeff80] Erroneous C2 Message random does not match up
    [rtmp @ 0x5595cebeff80] App field don't match up: test <-> live
    [rtmp @ 0x5595cebeff80] Unexpected stream teststream?, expecting stream
    Input #0, live_flv, from 'rtmp://0.0.0.0:19350/live/stream':
    Metadata:
    encoder         : Lavf59.16.100
    server          : SRS/6.0.23(Bee)
    server_version  : 6.0.23
    Duration: N/A, start: 0.042000, bitrate: N/A
    Stream #0:0: Video: h264 (High), yuv420p(progressive), 1280x720 [SAR 1:1 DAR 16:9], 23.98 fps, 23.98 tbr, 1k tbn
    Stream #0:1: Audio: aac (LC), 44100 Hz, stereo, fltp
    Output #0, flv, to 'rtmp://127.0.0.1:29350/test/teststream':
    Metadata:
    server_version  : 6.0.23
    server          : SRS/6.0.23(Bee)
    encoder         : Lavf59.16.100
    Stream #0:0: Video: h264 (High) ([7][0][0][0] / 0x0007), yuv420p(progressive), 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 23.98 fps, 23.98 tbr, 1k tbn
    Stream #0:1: Audio: aac (LC) ([10][0][0][0] / 0x000A), 44100 Hz, stereo, fltp
    Stream mapping:
    Stream #0:0 -> #0:0 (copy)
    Stream #0:1 -> #0:1 (copy)
    Press [q] to stop, [?] for help
    frame=  978 fps= 28 q=-1.0 size=    6838kB time=00:00:40.75 bitrate=1374.6kbits/s speed=1.16x

    image

TRANS_BY_GPT3

jb-alvarado commented 1 year ago

No is the same problem, as you see in ffmpeg line:

[rtmp @ 0x5595cebeff80] Unexpected stream teststream?, expecting stream

The question mark by teststream? should be not there. At the moment ffmpeg does not really care about streaming address, as long protocol matches everything got excepted. So it only prints a warning.

But in my case as I wrote it is a problem, because I filter for that Unexpected stream messages.

chundonglinlin commented 1 year ago

Okey, I will trace ffmpeg rtmppoto.c that when ffmpeg call rtmp_open(), checked rtmp_server_handshake() get a log print, such as,

[rtmp @ 0x560054272f80] Erroneous C2 Message epoch does not match up with C1 epoch
[rtmp @ 0x560054272f80] Erroneous C2 Message random does not match up

And when parse rtmp_parse_result, you can get a RTMP_PT_INVOKE message for handle_invoke. However found not FCPublish message, maybe detect following logs,

[rtmp @ 0x560054272f80] Unexpected stream teststream?, expecting teststream

You can also trace the entire link by debugging ffmpeg, such function call relation,

--> rtmp_open() --> rtmp_server_handshake()
get_packet() --> rtmp_parse_result() --> handle_invoke() --> send_invoke_response()
rtmp_write() --> rtmp_parse_result() --> handle_invoke() --> send_invoke_response()
jb-alvarado commented 1 year ago

Thank for your effort! So you think this issue is related to ffmpeg? Then I need to see, how I will manage the problem.