In one of my applications, we hit another server using HttpURLConnection - the application worked for fine for months, and now suddenly all hits are facing a connection timeout. Intermittently, a few calls (1 in 500) succeed while all others fail. The application is deployed on Linux running on Java 5 with Tomcat 5.5. I have tried a curl and wget from command line which work fine.
Another Java process using exactly the same code base is able to make connections from command line. We have restarted the tomcat server as well as the machine but to no avail. We have thoroughly checked the machine and there are no blocking processes/firewalls hindering with this (evident that other Java processes are able to make connections).
In intermittent bursts (say once a day) the application is able to establish a few connections and then returns back to the broken state. Not much is evident from the stack trace as well.
Any suggestions where it might be going wrong?