• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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:
     
    Marshal
    Posts: 28177
    95
    Eclipse IDE Firefox Browser MySQL Database
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    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
    Posts: 3
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    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
    Posts: 3
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    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.
     
    With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    reply
      Bookmark Topic Watch Topic
    • New Topic