Search code examples
jakarta-eewebsphere-7java-6http-status-code-503

Websphere 7.0 throwing 503 exactly after 180 seconds when the external service hasn't replied yet


I developed a struts2 application that writes the files to an external system (RESTful web service that has been written in PHP) which has to convert the files to TIFF and also scan these files. Here's the code snippet:

    HttpURLConnection conn = getConnection(Resource.VIRUS_SCAN_URL.getValue(), Constants.POST);
    conn.setDoInput(true);
    conn.setDoOutput(true);
    OutputStreamWriter writer = new OutputStreamWriter(conn.getOutputStream(), Constants.UTF8);

    String payload = createJsonString(dto);
    writer.write(payload);
    writer.close();

    BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream()));
    StringBuffer jsonString = new StringBuffer();

The problem is that when the files are big and the external system takes longer than 180 seconds (3 minutes) my server (websphere 7.0) throws 503 exception. I am sure that the problem is with the server configuration because with the same set of files, I tried submitting the files from jboss server, it took 5 minutes and the response was successful.

What I have tried is to configure the WSHTTP timeout settings by changing it from 180 to 500 according to this guide but my server still behaving as is.

Any guidance in this respect is highly appreciated.


Solution

  • I have finally resolved the issue. The issue is not with the configuration. I added

    conn.setConnectTimeout(0);
    

    to the connection object and it solved the issue.