title: Server returned HTTP response code: 500 for URL due to program execution time?
body: <p>I am calling a REST API, which will internally connect to 2000 servers(single host at a time) and collect the information and send back the response to my java program in a XML format.  to connect to each host and get the response is around 30 secs. I am using HTTPUrlConnection to get a XML response from this web service. I do not have control over the rest API, i can just consume it using the endpoint URL. when i run the program, i am getting java.io.IOException: Server returned HTTP response code: 500 for URL: http://. Is this exception valid? as the actual API has to connect to multiple hosts and get response and by that time my server is responding with 500 status. if this is the case, is there any other better way to solve this issue? Please suggest.</p>