2

I am making a REST call which takes around 2 or 3 minutes to respond, but I am getting a connect timed out exception. How do I increase the timeout for the REST call that is being made.

Here is the code snippet,

    Client restClient = Client.create();
    WebResource webResource = restClient.resource(requestURL);
    ClientResponse response =  webResource.accept("application/json").header("Authorization", authStringEnc)
                .get(ClientResponse.class);
        if (response.getStatus() != 200)
        {
            throw new RuntimeException("Failed : HTTP error code : " + response.getStatus());
        }

Kindly help me solve this issue.

dwarakesh tp
  • 127
  • 4
  • 13
  • 1
    Possible duplicate of [How to set the connection timeout with Jersey 2](http://stackoverflow.com/questions/19543209/how-to-set-the-connection-timeout-with-jersey-2) – rorschach Aug 30 '16 at 12:14

1 Answers1

2

Or you can change the request header like:

Connection: Keep-Alive Keep-Alive: timeout= set_your_desired_time limit

Salahin Rocky
  • 415
  • 9
  • 18
  • @dwarakeshtp can you accept this as an answer if this worked for you. So that it is helpful for others – koiralo Jul 09 '19 at 09:54