1

I've been working for 24 hours to find the problem with this online stream : http://str45.streamakaci.com:8014 you can try it and it's working but when i try to get the header from it using Java i get this :

Sending 'GET' request to URL : http://str45.streamakaci.com:8014
Response Code : -1
Response Message : {Content-type=[unknown/unknown]}

When i use SMSSniffer to see what happen to HTTP headers returned are correct and i get this

GET / HTTP/1.1
Content-Type: text/html; charset=UTF-8
Icy-MetaData: 1
Accept-Encoding: gzip
Content-Encoding: gzip, deflate
Cache-Control: no-cache
User-Agent: Java/1.8.0_131
Host: str45.streamakaci.com:8014
Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
Connection: keep-alive


ICY 200 OK
icy-notice1:<BR>This stream requires <a href="http://www.winamp.com/">Winamp</a><BR>
icy-notice2:SHOUTcast Distributed Network Audio Server/Linux v1.9.8<BR>
icy-name:Radio Flemme MP3
icy-genre:Various
icy-url:http://www.radioflemme.com
content-type:audio/mpeg
icy-pub:0
icy-metaint:32768
icy-br:128 

with some long text below the headers.

here is the Java code to get the HTTP header which work fine with other ShoutCast stream but not this one.

 private static void sendGet() throws Exception {

            String url = "http://str45.streamakaci.com:8014";

            HttpURLConnection httpClient =
                    (HttpURLConnection) new URL(url).openConnection();

            // optional default is GET
             httpClient.setRequestMethod("GET");

            //add request header
             httpClient.setRequestProperty("Content-Type", "text/html; charset=UTF-8");

            httpClient.setRequestProperty("Icy-MetaData", "1");
            httpClient.setRequestProperty("Accept-Encoding", "gzip");
            httpClient.setRequestProperty("Content-Encoding", "gzip, deflate");
            httpClient.setRequestProperty("Cache-Control", "no-cache");
           int responseCode = httpClient.getResponseCode();
            System.out.println("\nSending 'GET' request to URL : " + url);
           System.out.println("Response Code : " + responseCode);

            String name = httpClient.getHeaderField("icy-metaint");
           // System.out.println("Response name : " + name);
            System.out.println("Response Message : " +  httpClient.getHeaderFields());

        }

Please can anyone help me to solve this problem. Regards

1
  • I have found that the stream send the Header information when you start to play the stream , is this normal ?
    – satyres
    Apr 7, 2020 at 0:59

2 Answers 2

0

URL http://str45.streamakaci.com:8014 does return the header properly, here is a command to check the headers in your terminal using lynx:

lynx -mime_header http://str45.streamakaci.com:8014
HTTP/1.0 200 OK
content-type:text/html

<HTML><HEAD><meta http-equiv="Content-Language" content="en-us"><meta http-equiv="Content-Type" content="text/html; charset=windows-1252"><meta http-equiv="Pragma" content="no-cache">.... HTML follows

It is not 100% clear what you are looking for, so just in case I will mention that http://str45.streamakaci.com:8014 URL is the address of Shoutcast "Status" page, not the audio stream. If you want audio stream the URL will be: http://str45.streamakaci.com:8014/;stream "stream" at the end here is not important and can be any string or even http://str45.streamakaci.com:8014/; will work fine. So, lets check the stream headers:

lynx -mime_header "http://str45.streamakaci.com:8014/;stream"
ICY 200 OK
icy-notice1:<BR>This stream requires <a href="http://www.winamp.com/">Winamp</a><BR>
icy-notice2:SHOUTcast Distributed Network Audio Server/Linux v1.9.8<BR>
icy-name:Radio Flemme MP3
icy-genre:Various
icy-url:http://www.radioflemme.com
content-type:audio/mpeg
icy-pub:0
icy-br:128

all this is not specific to Java, I can not tell you the code, but can confirm that this Shoutcast is returning headers the right way.

5
  • Thanks for your reply , what i want is to get the icy header so i can extract the data i need like meta-int ,but even when i add the /; at the end of the stream i still get the same result . this is not happening to all shoutcast stream only some of them , please try the java code
    – satyres
    Apr 7, 2020 at 11:22
  • If you try another url for example : 38.99.146.102:8000 , it works fine and return the informations needed.i'm really desperate !
    – satyres
    Apr 7, 2020 at 15:17
  • 38.99.146.102:8000 is shoutcast version 2 where they fixed the header to be more standard compatible Apr 7, 2020 at 16:20
  • I don't own the server , i can't change the headers standard . is there any work around this ? Thanks
    – satyres
    Apr 7, 2020 at 17:29
  • I suspect Java has a way to read HTTP reader "raw" way, if your library/classes can not parse the non-standard ICY headers - this is the only way I think. Apr 7, 2020 at 17:39
0

It seems that your HTTP client isn't compatible with the response status line:

ICY 200 OK

For a normal HTTP connection, this response is something like HTTP/1.0 200 OK. Older clients supported this and treated the connection like HTTP 1.0 or 0.9, but somewhere along the way we've steadily lost this capability.

Ideally, you replace this server with something modern. Icecast is a drop-in replacement for you and also supports HTTPS. There are newer versions of the SHOUTcast DNAS, but HTTPS is a hassle and has additional licensing requirements so I don't even bother with it these days. And of course, you could also go HLS and not need a specialized streaming server at all. (Just understand the tradeoff there in terms of compatibility and latency.)

If you are not in control of the server, you will need to override your HTTP client somehow, to allow it to accept that ICY-style status line. If you are unable to do that, you're stuck making a regular TCP connection and parsing the response yourself.

2
  • Hi Thanks for your reply , i don't own the server , and this just was an example , i didn't have problem with other streams (shoutcast ,icecast...) but for some of them i don't have any idea how to deal with . i need to get the Icy-MetData to get the current stream information. Any way please tell me how to override the HTTP to get the right headers. i don't have any idea about it.
    – satyres
    Apr 7, 2020 at 15:50
  • i"ve used this script stackoverflow.com/questions/8970548/… but t not working too.i don't really understand what is going on
    – satyres
    Apr 7, 2020 at 18:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.