Antony Prince
Antony Prince

Reputation: 319

How Avoid Gateway timeout exception by incresing http response time

Have a java application which makes a http call to a ruby application which execute certain sql queries and gives back an http response of 200 to the java appilcation if success, My problem is the ruby application takes more than 5min to complete the execution while checking the log of the java application after almost 3min it is given as gateway time out exception.How to solve this problem?

java http call to ruby application:

GetMethod get = new GetMethod(URL to ruby application);

    Exception exception = null;
    try {
        // Get HTTP client
        HttpClient httpclient = new HttpClient();
        int resultCode = httpclient.executeMethod(get);

        // Display status code
        if (log.isInfoEnabled()) {
            log.info("response status code: "
                    + resultCode);
            // Display response
            log.info("Response body: " + get.getResponseBodyAsString());
        }
        if (resultCode != 200) {
            log.error("Failed with status code: "
                    + resultCode);
            log.error("Response body: " + get.getResponseBodyAsString());
        }

    }

Upvotes: 1

Views: 3318

Answers (1)

danysz
danysz

Reputation: 628

You can use this response to change the timeout... Something is wrong with the architecture because nobody is sending requests and wait 5 minutes for an answer in an application.

Probably you should send the requests and return "200" (OK) if all the parameters of the request are ok (so the queries can be done) and when the results are ready (after 5 minutes) you can do few things:

a. to use a socket connection between the server and the client and send to the client the result. b. much more useful : to send a push notification with the results (don't forget that today you can load 4 k of data on the push notification.

Upvotes: 1

Related Questions