You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by Christopher Svanefalk <ch...@gmail.com> on 2013/11/12 05:36:08 UTC

HTTPClient never leaves socketRead() when executing GET on a ShoutCast stream

Dear community,

I am using Apache HttpClient (from Apache HTTP Components 4.3) in order to
execute a GET against a ShoutCast stream. The following code can be used to
reproduce this what I want to do:

CloseableHttpClient client = HttpClients.createDefault();
HttpGet request = new HttpGet("http://relay3.181.fm:8062/");
CloseableHttpResponse response = client.execute(request);

The call to client.execute() never returns, and according to the debugger
it is a nested invocation to java.net.SocketInputStream#socketRead0() which
is the last node in the call stack. From profiling the code, my only
conclusion (based on a steadily rising number of char[] allocations) is
that it simply "latches on" to the stream and keeps pulling bytes from the
socket indefinitely.

What I would like is for the client to simply work normally and give me a
HTTPResponse which I can use to pull what I want from the stream. As a
matter of fact, I have been able to do so with other ShoutCast streams, but
not this one.

Is there any way to work around this? Could I for example tell the client
to break off after a certain number of bytes?

*Best,*

    *Christopher Svanefalk*

*    Web:* http://www.csvanefalk.com/ <http://csvanefalk.com/>
*    GitHub:* https://github.com/csvan
*    Cell:* +46762628251
    *Skype:* csvanefalk



    <http://www.linkedin.com/in/csvanefalk>