Windows – How diagnose why Java app fails to open a socket (after running successfully for a while)

javasocketwindows

I'm trying to diagnose why a Java-based app runs for a while as a client making SOAP webservice calls, and then starts hitting an exception whereby it cannot open a socket. The OS is Windows 2003 server SP1.

The netstat -an output shows some connections in CLOSE_WAIT or TIME_WAIT, but not enough to suggest that the OS itself is out of sockets.

I suspect that there's an error in the way that the client-side API is being used (Axis2 v1.4), such that it fails to recycle some internal resource. Once we hit the condition of not being able to open a socket, we have to restart the Java app. (Somewhat strangely, though, we can still make a call out using simple java.net.URL).

I'm wondering if we can use Wireshark/Ethereal or similar to help diagnose the problem from an OS/network standpoint?

In case it is useful, our Java stack trace is:

Caused by: java.net.ConnectException: Connection timed out: connect at
java.net.PlainSocketImpl.socketConnect(Native Method) at
java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333) at
java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195) at
java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182) at
java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366) at
java.net.Socket.connect(Socket.java:516) at
java.net.Socket.connect(Socket.java:466) at
java.net.Socket.(Socket.java:366) at
java.net.Socket.(Socket.java:239)

Many thanks for any insight.
Dan Haywood

Best Answer

The first line in the Java stack trace says java.net.ConnectException: Connection timed out. This indicates that the client side successfully created its client socket and attempted to contact the server, however no response came back. Your problem is not in the client. My advice is to investigate whether the remote server is up. Next ensure there is no networking issue preventing the client from contacting the server.

Related Topic