AirenSoft / OvenMediaEngine

OvenMediaEngine (OME) is a Sub-Second Latency Live Streaming Server with Large-Scale and High-Definition. #WebRTC #LLHLS
https://airensoft.com/ome.html
GNU Affero General Public License v3.0
2.59k stars 1.06k forks source link

Dev image does not send proper url for webhook callbacks #1739

Open naanlizard opened 2 days ago

naanlizard commented 2 days ago

Describe the bug On the latest dev image (airensoft/ovenmediaengine@sha256:773acc79230548f8d942b2321f94d10e0846135128a5b0dc35eab60ff0fa528e), admission webhooks do not work because the URL sent does not include the streamkey

To Reproduce Steps to reproduce the behavior: Server.xml

(Note, in Server.xml, the Decodes section is either commented out (for 0.17.1) or uncommented (for dev)

Dockerfile

Maybe relevant, if you put the streamkey in the URL (e.g. in OBS, your rtmp url is set to rtmp://ingest.hostname.tld:1935/live/streamkey) both versions work.

Expected behavior URL sent should include the streamkey, like on 0.17.1.

Logs Relevant log lines from our backend API, Parameters being the values from the request OME sends

0.17.1 Parameters: {"client"=>{"address"=>"x", "port"=>58323, "real_ip"=>"x"}, "request"=>{"direction"=>"incoming", "protocol"=>"RTMP", "status"=>"opening", "time"=>"2024-11-14T15:23:54.039+00:00", "url"=>"rtmp://ingest.hostname.tld:1935/live/streamkey"}, "stream"=>{}}

dev Parameters: {"client"=>{"address"=>"x", "port"=>58619, "real_ip"=>"x"}, "request"=>{"direction"=>"incoming", "protocol"=>"RTMP", "status"=>"opening", "time"=>"2024-11-14T15:28:11.658+00:00", "url"=>"rtmp://ingest.hostname.tld:1935/live"}, "stream"=>{}}

Additional info:

Interestingly, it seems like the closing webhook does send the streamkey in the URL

Request params: {"direction"=>"incoming", "new_url"=>"rtmp://ingest.hostname.tld:1935/live/streamkey", "protocol"=>"RTMP", "status"=>"closing", "time"=>"2024-11-14T15:27:15.762+00:00", "url"=>"rtmp://apollo-rtmp://ingest.hostname.tld:1935/live/streamkey"}

Double checked the above, it seems like it does NOT send the streamkey in the closing call, or at least not always. Strange

dimiden commented 1 day ago

@naanlizard Thank you for the report! Upon reviewing the issue you mentioned, I found that a recent improvement in the URL parsing process caused the problem. I have just fixed this issue and committed it as 9f92959b946e8fd632c56ae87d803b8d78b5375f.

naanlizard commented 18 hours ago

The proper URL is now sent, but there's a new problem, which I'm not sure how to describe

When I start, the stream immediately stops, even though the backend returns an authorized

Backend logs (slightly modified for clarity with some lines removed for irrelevant things our backend is doing - fundamentally, it's doing the right thing I think is the point, this is the same code as on our production server)

I, [2024-11-16T17:17:51.137604 #190]  INFO -- : [319dc37e-f979-4892-a80b-2d1ab2ead660] Started POST "/streams/publish" for x at 2024-11-16 17:17:51 +0000
I, [2024-11-16T17:17:51.139766 #190]  INFO -- : [319dc37e-f979-4892-a80b-2d1ab2ead660] Processing by StreamsController#publish as JSON
I, [2024-11-16T17:17:51.139873 #190]  INFO -- : [319dc37e-f979-4892-a80b-2d1ab2ead660]   Parameters: {"client"=>{"address"=>"x", "port"=>56813, "real_ip"=>"x"}, "request"=>{"direction"=>"incoming", "protocol"=>"RTMP", "status"=>"opening", "time"=>"2024-11-16T17:17:51.135+00:00", "url"=>"rtmp://subdomain-ingest.hostname.tld:1935/live/streamkey"}, "stream"=>{}}
I, [2024-11-16T17:17:51.140378 #190]  INFO -- : [319dc37e-f979-4892-a80b-2d1ab2ead660] Starting publish action
I, [2024-11-16T17:17:51.140454 #190]  INFO -- : [319dc37e-f979-4892-a80b-2d1ab2ead660] Request params: {"direction"=>"incoming", "protocol"=>"RTMP", "status"=>"opening", "time"=>"2024-11-16T17:17:51.135+00:00", "url"=>"rtmp://subdomain-ingest.hostname.tld:1935/live/streamkey"}
I, [2024-11-16T17:17:51.140556 #190]  INFO -- : [319dc37e-f979-4892-a80b-2d1ab2ead660] Extracted token: streamkey
D, [2024-11-16T17:17:51.142152 #190] DEBUG -- : [319dc37e-f979-4892-a80b-2d1ab2ead660]   Stream Load (0.7ms)  SELECT `streams`.* FROM `streams` WHERE `streams`.`id` = 1 LIMIT 1
I, [2024-11-16T17:17:51.143132 #190]  INFO -- : [319dc37e-f979-4892-a80b-2d1ab2ead660] Fetched stream: #<Stream id: 1, title: "Stream", description: nil, slug: "username", token: "streamkey", live_since: nil, adult: true, in_multi: false, parent_stream_id: nil, user_id: 1, created_at: "2024-11-16 02:00:57.721218000 +0000", updated_at: "2024-11-16 17:16:35.570224000 +0000", rendered_description: "<p></p>", last_seen: "2024-11-16 17:16:35.568285000 +0000", offline_image: nil, banner: nil, banner_link: nil, viewers_count: 0, preview: nil>
D, [2024-11-16T17:17:51.144171 #190] DEBUG -- : [319dc37e-f979-4892-a80b-2d1ab2ead660]   User Load (0.3ms)  SELECT `users`.* FROM `users` WHERE `users`.`id` = 1 LIMIT 1
I, [2024-11-16T17:17:51.144478 #190]  INFO -- : [319dc37e-f979-4892-a80b-2d1ab2ead660] Authorization succeeded. Setting stream to live.

I, [2024-11-16T17:17:51.178706 #91]  INFO -- : [23f53614-0876-4402-a453-871142cd4b3e] Started POST "/streams/publish" for x at 2024-11-16 17:17:51 +0000
I, [2024-11-16T17:17:51.180101 #91]  INFO -- : [23f53614-0876-4402-a453-871142cd4b3e] Processing by StreamsController#publish as JSON
I, [2024-11-16T17:17:51.180216 #91]  INFO -- : [23f53614-0876-4402-a453-871142cd4b3e]   Parameters: {"client"=>{"address"=>"x", "port"=>56813, "real_ip"=>"x"}, "request"=>{"direction"=>"incoming", "new_url"=>"://", "protocol"=>"RTMP", "status"=>"closing", "time"=>"2024-11-16T17:17:51.177+00:00", "url"=>"rtmp://subdomain-ingest.hostname.tld:1935/live/streamkey"}, "stream"=>{}}
I, [2024-11-16T17:17:51.180688 #91]  INFO -- : [23f53614-0876-4402-a453-871142cd4b3e] Starting publish action
I, [2024-11-16T17:17:51.180754 #91]  INFO -- : [23f53614-0876-4402-a453-871142cd4b3e] Request params: {"direction"=>"incoming", "new_url"=>"://", "protocol"=>"RTMP", "status"=>"closing", "time"=>"2024-11-16T17:17:51.177+00:00", "url"=>"rtmp://subdomain-ingest.hostname.tld:1935/live/streamkey"}
I, [2024-11-16T17:17:51.180807 #91]  INFO -- : [23f53614-0876-4402-a453-871142cd4b3e] Extracted token: streamkey
D, [2024-11-16T17:17:51.181696 #91] DEBUG -- : [23f53614-0876-4402-a453-871142cd4b3e]   Stream Load (0.5ms)  SELECT `streams`.* FROM `streams` WHERE `streams`.`id` = 1 LIMIT 1
I, [2024-11-16T17:17:51.182434 #91]  INFO -- : [23f53614-0876-4402-a453-871142cd4b3e] Fetched stream: #<Stream id: 1, title: "Stream", description: nil, slug: "garrett", token: "streamkey", live_since: "2024-11-16 17:17:51.145101000 +0000", adult: true, in_multi: false, parent_stream_id: nil, user_id: 1, created_at: "2024-11-16 02:00:57.721218000 +0000", updated_at: "2024-11-16 17:17:51.146750000 +0000", rendered_description: "<p></p>", last_seen: "2024-11-16 17:16:35.568285000 +0000", offline_image: nil, banner: nil, banner_link: nil, viewers_count: 0, preview: nil>
D, [2024-11-16T17:17:51.183619 #91] DEBUG -- : [23f53614-0876-4402-a453-871142cd4b3e]   User Load (0.4ms)  SELECT `users`.* FROM `users` WHERE `users`.`id` = 1 LIMIT 1
I, [2024-11-16T17:17:51.183960 #91]  INFO -- : [23f53614-0876-4402-a453-871142cd4b3e] Stream is closing. Stream ID: 1

omebug111624.log-clean.txt

Dockerfile is the same as above but with

FROM airensoft/ovenmediaengine@sha256:0510bb6178a96083139a66b601c8aceeba5bb787f2e5694c8abfbcbb0010edef