Configuring TCP socket timeout

I have a Java application that uses a 3rd party COM component through a Java-COM bridge. This COM component opens a socket connection to a remote host.

It may take a while for this host to respond and I am suspicious that I am getting a timeout. I'm not sure because, as I said, this is a closed source third party component.

The API of this component does not provide me with a socket, so I have no way to set the timeout. So I am wondering if there is a way to set the default timeout for the system.

I am using Windows Server 2008 x64 Enterprise Edition.

+1


a source to share


4 answers


Do you want to create an application so that it knows at runtime if a timeout has occurred, or do you want to test the behavior of a closed source COM component? If it's the latter, install Wireshark in your dev box and watch the connection. If it's the first, you want your Java call to the homeland not to hang forever? If so, take a look at the java.util.concurrent executor service stuff - there is a way to call a method on a different thread and wait no more than N seconds before returning control to your thread.



+1


a source


You can inject your own SocketImplFactory (see the static setSocketImpl () method of the java.net.Socket class). Then you can create SocketImpl objects with your own SO_TIMEOUT parameter value.



0


a source


The registry settings described in Microsoft's "Windows Vista Tcp Ip Configuration Settings" for TcpMaxDataRetransmissions may allow you to set the global timeouts that you need.

You should of course be careful not to damage the rest of the server in the process by delaying responses to real errors.

0


a source


If you want to see the connection being established and then perhaps drop the timeout, you can use TCPview: http://technet.microsoft.com/en-us/sysinternals/bb897437.aspx

0


a source







All Articles