Quantcast

Runnable hangs using jersey-apache-client4 1.19

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Runnable hangs using jersey-apache-client4 1.19

Martynas Jusevičius
Hey all,

I have been successfully using jersey-apache-client4 for a while, but
after I refactored the application to use multiple threads, the client
requests in Runnable seem to hang.

I am using Jersey 1.19 and passing Client to threads spawned by a
thread pool in ServletContextListener. The code in Runnable that reads
the stream from ClientResponse

        InputStream is = fileResponse.getEntityInputStream();

seems to hang - the debugger steps to the next line that attempts to
read, and after that the Runnable never continues.

I am using ThreadSafeClientConnManager which is supposed to be
thread-safe. In the log I can see some lines as

    15:36:00,225 DEBUG ConnPoolByRoute:523 - No free connections
[HttpRoute[{}->http://localhost:8080]][null]

So I tried to increase the connection limits for my main routes:

        ThreadSafeClientConnManager cm = new ThreadSafeClientConnManager();
        HttpRoute localhost = new HttpRoute(new HttpHost("localhost", 8080));
        HttpRoute remote = new HttpRoute(new HttpHost("remote.com", 1982));
        cm.setDefaultMaxPerRoute(50);
        cm.setMaxForRoute(localhost, 50);
        cm.setMaxForRoute(remote, 50);
        cm.setMaxTotal(100);

 clientConfig.getProperties().put(ApacheHttpClient4Config.PROPERTY_CONNECTION_MANAGER,
cm);

This doesn't seem to have any effect though. Any clues?

Thanks.

Martynas
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Runnable hangs using jersey-apache-client4 1.19

Martynas Jusevičius
Turned out to be not an HTTP problem after all. Sorry!

On Sun, Dec 4, 2016 at 3:50 PM, Martynas Jusevičius
<[hidden email]> wrote:

> Hey all,
>
> I have been successfully using jersey-apache-client4 for a while, but
> after I refactored the application to use multiple threads, the client
> requests in Runnable seem to hang.
>
> I am using Jersey 1.19 and passing Client to threads spawned by a
> thread pool in ServletContextListener. The code in Runnable that reads
> the stream from ClientResponse
>
>         InputStream is = fileResponse.getEntityInputStream();
>
> seems to hang - the debugger steps to the next line that attempts to
> read, and after that the Runnable never continues.
>
> I am using ThreadSafeClientConnManager which is supposed to be
> thread-safe. In the log I can see some lines as
>
>     15:36:00,225 DEBUG ConnPoolByRoute:523 - No free connections
> [HttpRoute[{}->http://localhost:8080]][null]
>
> So I tried to increase the connection limits for my main routes:
>
>         ThreadSafeClientConnManager cm = new ThreadSafeClientConnManager();
>         HttpRoute localhost = new HttpRoute(new HttpHost("localhost", 8080));
>         HttpRoute remote = new HttpRoute(new HttpHost("remote.com", 1982));
>         cm.setDefaultMaxPerRoute(50);
>         cm.setMaxForRoute(localhost, 50);
>         cm.setMaxForRoute(remote, 50);
>         cm.setMaxTotal(100);
>
>  clientConfig.getProperties().put(ApacheHttpClient4Config.PROPERTY_CONNECTION_MANAGER,
> cm);
>
> This doesn't seem to have any effect though. Any clues?
>
> Thanks.
>
> Martynas
Loading...