ossrs / srs

SRS is a simple, high-efficiency, real-time video server supporting RTMP, WebRTC, HLS, HTTP-FLV, SRT, MPEG-DASH, and GB28181.
https://ossrs.io
MIT License
24.86k stars 5.29k forks source link

on_publish action in HTTP Hook done not return all param as expect #3791

Closed wangborong12345 closed 10 months ago

wangborong12345 commented 10 months ago

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

Description

English: I use the RTMP URL: rtmp://yulee.local:1935/live/livestream?secret=spy&token=hellotoken to push the stream. Then, I can receive the on_publish action in the HTTP Hook. Up to this point, everything works fine. However, ?secret=spy&token=hellotoken does not exist in the on_publish action request parameter. It only sends "?secret=spy" in the param field.

Chinese: I use the URL: rtmp://yulee.local:1935/live/livestream?secret=spy&token=hellotoken to push the stream to SRS, and everything is working fine. Then, I ran the main branch of SRS Stack, and debugged the method on line 54 in srs_hooks.go, which is the HTTP Hook for on_publish. I found that the request parameters for the on_publish Hook are incomplete, missing &token=hellotoken and only having ?secret=spy.

  1. SRS Version: 5.0

  2. SRS Config:

    http_hooks {
        enabled         on;
        on_publish      http://172.17.0.1:2024/terraform/v1/hooks/srs/verify;
        on_unpublish    http://172.17.0.1:2024/terraform/v1/hooks/srs/verify;
        on_play         http://172.17.0.1:2024/terraform/v1/hooks/srs/verify;
        on_stop         http://172.17.0.1:2024/terraform/v1/hooks/srs/verify;
        on_hls          http://172.17.0.1:2024/terraform/v1/hooks/srs/hls;
    }

Replay

Please describe how to replay the bug?

Step 1:

ffmpeg -f gdigrab -framerate 2 -i desktop -c:v libx264 -x264-params "bframes=0" \
  -profile:v baseline -b:v 100k -s 1280x720 -preset veryfast -tune zerolatency  -pix_fmt yuv420p \
  -f flv rtmp://yulee.local:1935/live/livestream?secret=spy&token=hellotoken

Step 2:

debug on_publish function

Expect

English: return all param, "?secret=spy&token=hellotoken"

Chinese: I think it should return all parameters.

TRANS_BY_GPT4

winlinvip commented 10 months ago

This is not a problem with the callback, but with your streaming command. In the bash command line, the special character & represents starting in the background. You should modify your command line:

ffmpeg -f gdigrab -framerate 2 -i desktop -c:v libx264 -x264-params "bframes=0" \
  -profile:v baseline -b:v 100k -s 1280x720 -preset veryfast -tune zerolatency  -pix_fmt yuv420p \
  -f flv "rtmp://yulee.local:1935/live/livestream?secret=spy&token=hellotoken"

Use double quotes or single quotes to avoid the & issue.

TRANS_BY_GPT4