Search code examples
clientjersey-2.0websphere-libertyjersey-clientsocket-timeout-exception

Jersey Client Call within Websephere throw java.net.SocketTimeoutException


I'm using Jersey Client in a Java Web App Running on WebSphere Liberty to fetch data located on another server. My web call is an HTTP POST and the data are sent as response. For short amount of data, the response is returned within few seconds, so no problem. The exception is thrown when the request takes a longer time. I notice that after 1 minute java.net.SocketTimeoutException: Read timed out is thrown

I took the same code, an plug it into a public static void main. There, even if the request takes 3 minutes, there is not Timeout. So I guess the issue is not in Jersey, but on some parameter in WebSphere. There is a bunch of parameters define here :

I try to increase few values in server.xml httpOptions: readTimeout, persistTimeout, and persistTimeout to 600 seconds but it doesn't solve the issue. I still get the timeout after 1 minute.

Is there any other parameter which controls this behavior? Best regards,


Solution

  • I found a solution: it is possible to set different timeout parameters on the client builder before creating the client.

    { 
        ClientBuilder cb =  ClientBuilder.newBuilder()
        cb.property("com.ibm.ws.jaxrs.client.timeout", "600000");   
        cb.property("com.ibm.ws.jaxrs.client.connection.timeout", "100000");    
        cb.property("com.ibm.ws.jaxrs.client.receive.timeout", "600000");    
        Client myclient = cb.build();
    }