File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Services and the fly likes Intermittent java.net.ConnectException: Connection timed out: connect Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Web Services
Bookmark "Intermittent java.net.ConnectException: Connection timed out: connect" Watch "Intermittent java.net.ConnectException: Connection timed out: connect" New topic
Author

Intermittent java.net.ConnectException: Connection timed out: connect

Wes Green
Greenhorn

Joined: Apr 18, 2012
Posts: 3
Good evening -

We are working on a web application that is running on a Server with Windows Server 2008 R2 (64-bit) and using Tomcat 7.0.25 to host the web application. We are trying to make a call to a web service that is on a server with Windows Server 2008 x86 (32-bit). There are no proxy servers in place.

The site has multiple pages on it and the web service is invoked once you reach the last page. What is happening is this:
  • The first time the page loads the connection times out to the web service, however if you refresh the page the connection is successful.
  • If you wait a couple of minutes and refresh the page the connection times out. Then if you refresh the page right after that the connection is successful.

  • Does anybody have any idea what could be causing this behavior?

    The exception that we receive in the code is below:
    Paul Clapham
    Bartender

    Joined: Oct 14, 2005
    Posts: 18570
        
        8

    It sounds to me like this: if the server hasn't been accessed for a while, then when you access it, whatever is running there takes so long to start up and respond that the client times out. But when the client retries within a short time, the server has finally lumbered into action and is ready to handle requests properly.

    I was a bit confused by the description of your setup, which appears to have two servers. But my guess (wild as it may be) is that the problem is with the web service's server, not with your server which is actually acting as the client.
    Wes Green
    Greenhorn

    Joined: Apr 18, 2012
    Posts: 3
    Thanks for the reply Paul.

    What you describe does seem to fit the issue. After the web service is invoked the first time (and times out) the connection always seems to work as long as you actively engage the web service. The connection doesn't time out until you close the browser or wait several minutes before invoking the web service again. The only use for that server is to host that one specific web service, other than that it sits dormant until accessed by the web application. I'll run that by our system admin tomorrow and see if that connection goes to sleep after a couple of minutes.

    To help clarify the below (since I was getting confused trying to describe it... ) I'll call the server that hosts the web application Server 1 and the server that hosts the web application Server 2

    To explain the setup a bit more: We needed two servers because the web service that we are calling will not install on a 64-bit operating system (it's a web service that was purchased from a vendor but is installed and hosted by us). So instead of re-building Server 1 our sys admin decided to build a new virtual server (server 2) that resides on Server 1.
    Wes Green
    Greenhorn

    Joined: Apr 18, 2012
    Posts: 3
    Thanks again for the help Paul!

    This issue seems to have been resolved. Our system admin made some network changes and I added the connectionTimeout attribute to the ssl connector on the tomcat's server.xml file. Hopefully if anybody else comes across this issue this may help point them in the right direction. Unfortunately I am unaware of the network changes that were made.
     
    GeeCON Prague 2014
     
    subject: Intermittent java.net.ConnectException: Connection timed out: connect