karlheyes / icecast-kh

KH branch of icecast
GNU General Public License v2.0
300 stars 107 forks source link

HTTP headers in aliases #390

Closed picpakdog closed 1 year ago

picpakdog commented 1 year ago

I'm migrating from Shoutcast to Icecast and I'm trying to stay backwards compatible with my streaming URL, e.g. https://stream.qcindie.com/; . Making a mount called /; doesn't work as the semicolon gets encoded. Relays and wildcard mounts were also not working. The only solution I've found is using

<alias source="/;" dest="/live"/>

This works well on web browsers, but in apps (TuneIn, etc.) it doesn't work as it's actually returning an HTML file, not the direct stream itself:

The /live mount:

~ curl -X GET -I https://stream.qcindie.com/live
HTTP/1.1 200 OK
Server: Icecast
Connection: Close
Pragma: no-cache
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, private
Vary: Origin
Access-Control-Allow-Origin: *
Access-Control-Allow-Headers: *
Access-Control-Expose-Headers: *
Date: Sun, 29 Jan 2023 16:55:57 GMT
Content-Type: audio/mpeg
icy-br: 128
icy-description: Regina's Alternative
icy-genre: Indie
icy-name: QCIndie
icy-pub: 1
icy-url: https://www.qcindie.com

The /; alias:

~ curl -X GET -I https://stream.qcindie.com/;    
HTTP/1.1 200 OK
Server: Icecast
Connection: Close
Pragma: no-cache
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, private
Vary: Origin
Date: Sun, 29 Jan 2023 16:57:16 GMT
Content-Type: text/html
Content-Length: 504

Is there a way to add the correct headers to the alias itself? I know the latest version does have header support, so could something like this be supported? Or is there a more elegant way I'm not seeing? I'm running 2.4.0-kh17 (win64).

karlheyes commented 1 year ago

This does not sound like a header issue. I don't have tunein to verify but the curl line may not be working as the ; is being handled by the shell, try the url in quotes.

As for tunein itself, cna you determine what is actually being requested by tunein in the non-working setup. Check the access log first, maybe the error log level 4 it nothing obvious.

karl

picpakdog commented 1 year ago

Good catch -- putting it in quotes shows the same results as the /live mount. Bizarrely, the TuneIn app seems to be trying to connect to / itself:

24.72.48.110 - - [29/Jan/2023:13:12:50 -0600] "GET / HTTP/1.1" 206 324 "-" "TuneIn Radio/24.7.0; iPhone11,8; iOS/16.3" 0
24.72.48.110 - - [29/Jan/2023:13:12:50 -0600] "GET / HTTP/1.1" 206 830 "-" "TuneIn Radio/24.7.0; iPhone11,8; iOS/16.3" 0

The error log also confirms this:

[2023-01-29  13:12:50] DBUG client/worker_add_pending_clients Added 1 pending clients to 0000026f6f0b1d00
[2023-01-29  13:12:50] DBUG connection/_handle_get_request start with /
[2023-01-29  13:12:50] DBUG connection/_handle_get_request alias has made / into /index.html
[2023-01-29  13:12:50] DBUG fserve/fserve_client_create checking for file /index.html (./web/index.html)
[2023-01-29  13:12:50] DBUG stats/modify_node_event update "global" file_connections (11171)
[2023-01-29  13:12:50] DBUG fserve/find_fh mount /index.html (0)
[2023-01-29  13:12:50] DBUG fserve/fh_add_client refcount now 1 for /index.html
[2023-01-29  13:12:50] DBUG format/format_file_read End of requested range (1)
[2023-01-29  13:12:50] DBUG fserve/remove_from_fh setting timeout as no clients on /index.html
[2023-01-29  13:12:50] DBUG client/client_destroy keepalive detected on 24.72.48.110, placing back onto worker

But playing on the web (https://tunein.com/radio/QCIndie-s253577/) correctly connects to /;. No idea why it would behave this way, but TuneIn is not the only app I've seen struggle with this setup.

karlheyes commented 1 year ago

It may filter the ; itself so do not be surprised on that. I believe it was like a separator like the ? is for http originally. I guess you should try having an alias of / to /live as well as /; The other thing of concern, which may be ok but from that log we can see a range request, I guessing it is 0-1.

If the issue i just the alias from / to /live then you should be fine, if the range request is an issue then we need to look further.

karl.

picpakdog commented 1 year ago

I really made a mountain out of a molehill with this one. Obviously after setting the aliases, all works fine. Interesting how a Shoutcast standard is treated quite differently in other programs and apps.

karlheyes commented 1 year ago

np, sometimes things can crop up that need investigating.