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

FLV: Unable to extract vhost from the app. #3562

Closed ysc3839 closed 5 months ago

ysc3839 commented 1 year ago

Description

When playing an http-flv stream with vhost, the value of the app parameter in the on_play hook is [vhost]/[app] instead of [app]. This behavior is inconsistent with the old version (2.x).

  1. SRS Version: 4.0-r4
  2. SRS Log: N/A
  3. SRS Config: N/A

Modify the code. https://github.com/ossrs/srs/blob/2573a25101514f0e3d152b96cd33b31bd00e136d/trunk/src/app/srs_app_http_stream.cpp#L708-L711

     SrsHttpMessage* hr = dynamic_cast<SrsHttpMessage*>(r);
     SrsRequest* nreq = hr->to_request(req->vhost);
     SrsAutoFree(SrsRequest, nreq);
+    srs_trace("SrsLiveStream::http_hooks_on_play req->app=%s nreq->app=%s", req->app.c_str(), nreq->app.c_str());

Log output.

[2023-05-31 17:59:55.017][Trace][17340][6ye70i78] SrsLiveStream::http_hooks_on_play req->app=live nreq->app=vlive/live

The temporary solution is to add nreq->app = req->app; but unsure if there are any other issues.

The documentation seems to have an issue. The example given on this page is http://192.168.1.100/live/livestream.flv?vhost=demo.srs.com&token=xxx, but it actually returns a 404 error.

Replay

Step 1: Push the RTMP stream to rtmp://127.0.0.1/live/livestream?vhost=vlive. Step 2: Play http://127.0.0.1/vlive/live/livestream.flv. Step 3: The app parameter in the on_play hook is vlive/live.

Expect

The app parameter should be live.

TRANS_BY_GPT3

winlinvip commented 1 year ago

As outlined in URL, the following formats should be used for the vhost. It is important to note that these formats are applicable to RTMP, HTTP-FLV, and HLS.

Some CDNs also support the subsequent format, which helps to prevent query strings containing special characters.

SRS is expected to be compatible with the previously mentioned format; however, there seems to be a problem with the last one, leading to an incorrect vhost in the HTTP callback.

winlinvip commented 1 year ago

As described in the URL, the following format should be used as vhost. It is important to note that these formats are applicable for RTMP, HTTP-FLV, and HLS.

Some CDNs also support the following format, which helps to avoid including special characters.

SRS needs to be compatible with the above format; however, the last format seems to have a bug that causes the vhost in the HTTP callback to be incorrect.

TRANS_BY_GPT3

duiniuluantanqin commented 1 year ago

I checked versions 5.0 and 6.0, and it seems that this issue is not present. However, I don't have enough time to check version 4.0. Could you try upgrading to the latest version and see if the issue still persists?

winlinvip commented 5 months ago

This issues is fixed in SRS 5.0+. Because SRS 4.0 is not maintained, upgrading to 5.0 or 6.0 is a better solution.