We have a front end Java web app, and a back end Java web app. The front end web app makes requests (using HttpURLConnection) from the back end web app.
When the two web apps are located on different servers, everything is fine. However, when we put them on the same server, we are getting "SocketTimeoutException: Read timed out" when we have 5 or more simultaneous HttpURLConnections.
We're using the GlassFish container (glassfish-installer-v2.1.1-b31g-linux.jar), but don't have much idea what the problem is. Here is our HttpURLConnection code used in the front end web app...
...as you can see, the method returns a HttpURLConnection, but that connection is always closed (in a 'finally' block), so what could the problem be?
I'm going to try putting this code in a new Thread but, apart from that, does anyone have any ideas, suggestions or explanations?!
I know when I use Websphere, the default is to disallow outbound socket connections, and it's necessary to include a policy file with the web application if it has to do that. Quite possibly that's a standard Java EE rule and you would have to do the same sort of thing with your Glassfish installation.
Unfortunately I haven't used Glassfish so I couldn't start to tell you how to do that, if indeed that's your problem.
Joined: Jan 22, 2004
The outbound connections are fine - it's when the connections are made to localhost that we have the problem... but the problem only occurs when there are 6 or more simultaneous requests to localhost...