Menu ▾ ▴

#1487 Streaming: WebClient.getPage() hangs on audio-stream

2.11
open
nobody
1
2014-09-23
2013-03-02
Wayne
No

I'm trying to getPage() for http://50.31.192.99

The content-type is an audio stream and it doesn't time out at all. The code hangs on the following line. If timeout doesn't work, I wonder if there is a way to specify response size and exit out of it if response exceeds the limit.

"main" prio=10 tid=0x00007f2924007000 nid=0x5d20 runnable [0x00007f292aa57000]
java.lang.Thread.State: RUNNABLE
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(SocketInputStream.java:146)
at org.apache.http.impl.io.AbstractSessionInputBuffer.read(AbstractSessionInputBuffer.java:204)
at org.apache.http.impl.conn.LoggingSessionInputBuffer.read(LoggingSessionInputBuffer.java:82)
at org.apache.http.impl.io.IdentityInputStream.read(IdentityInputStream.java:97)
at java.io.InputStream.read(InputStream.java:101)
at org.apache.http.conn.EofSensorInputStream.read(EofSensorInputStream.java:155)
at com.gargoylesoftware.htmlunit.HttpWebConnection.downloadContent(HttpWebConnection.java:687)
at com.gargoylesoftware.htmlunit.HttpWebConnection.downloadResponseBody(HttpWebConnection.java:669)
at com.gargoylesoftware.htmlunit.HttpWebConnection.getResponse(HttpWebConnection.java:195)
at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseFromWebConnection(WebClient.java:1486)
at com.gargoylesoftware.htmlunit.WebClient.loadWebResponse(WebClient.java:1403)
at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:305)
at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:374)
at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:359)
....

The source code is as following:

    final WebClient webClient = new WebClient(BrowserVersion.FIREFOX_3_6);
    webClient.getOptions().setTimeout(timeout*1000);
    // webClient.getOptions().setTimeout(5000);
    webClient.getOptions().setThrowExceptionOnScriptError(false);
    webClient.getOptions().setRedirectEnabled(true);
    webClient.getOptions().setThrowExceptionOnFailingStatusCode(false);
    webClient.getOptions().setUseInsecureSSL(true);
    webClient.setRefreshHandler(new HtmlunitWaitingRefreshHandler(timeout));
    // webClient.setRefreshHandler(new ThreadedRefreshHandler());
    java.util.logging.Logger.getLogger("com.gargoylesoftware.htmlunit").setLevel(Level.OFF);
    try {
        System.out.println("Opening page: " + urlWithProto);
        final HtmlPage page = webClient.getPage(urlWithProto);
         ....

Discussion

  • Wayne

    Wayne - 2013-03-02

    I'm actually using 2.12-SNAPSHOT

     
  • Wayne

    Wayne - 2013-03-05

    The response header is:
    HTTP/1.0 200 OK^M
    Content-Type: audio/mpeg^M
    icy-br:48^M
    ice-audio-info: bitrate=48^M
    icy-description:NHPR^M
    icy-genre:Talk^M
    icy-name:NHPR^M
    icy-pub:0^M
    icy-url:nhpr.org^M
    Server: Icecast 2.3.2^M
    Cache-Control: no-cache^M

    I wonder if there is an option on WebClient to not automatically read the content if in certain type.

     
  • Ahmed Ashour

    Ahmed Ashour - 2013-10-06
    • summary: WebClient.getPage() hangs on audio-stream --> Streaming: WebClient.getPage() hangs on audio-stream
     

Log in to post a comment.