I have some pretty basic old school socket related code used within a tomee servlet to connect to another servlet on another server.
The problem is that it appears that connections are being dropped and the "client" side is never released. No exception, EOF, etc appears.
Is this possible?
Here is the boiler plate code:
private Object sendObject(URL servlet, Serializable obj) throws Exception
{
HttpURLConnection connection = null;
InputStream inputstream = null;
ObjectOutputStream objectoutputstream = null;
ObjectInputStream result = null;
Object payload = null;
try
{
// Set the HostnameVerifier regardless of whether SSL is enabled.
HostnameVerifier hv = new HostnameVerifier()
{
public boolean verify(String urlHostName, SSLSession session)
{
return true;
}
};
HttpsURLConnection.setDefaultHostnameVerifier(hv);
connection = (HttpURLConnection) servlet.openConnection();
// Prepare for both input and output
connection.setDoInput(true);
connection.setDoOutput(true);
// Turn off caching
connection.setUseCaches(false);
connection.setRequestMethod("POST");
// Set the content type to be application/x-java-serialized-object
connection.setRequestProperty("Content-Type", "application/x-java-serialized-object");
setupHeaderAttributes(getHttpHeaders());
setupSessionCookies(getHttpHeaders());
// Load/add httpHeaders
addHeadersToConnection(connection, getHttpHeaders());
// Write the serialized object as post data
objectoutputstream = new ObjectOutputStream(connection.getOutputStream());
objectoutputstream.writeObject(obj);
objectoutputstream.flush();
// Get ready to receive the reply.
inputstream = connection.getInputStream();
setHttpStatus(connection.getResponseCode());
if (getHttpStatus() == HttpURLConnection.HTTP_OK)
{
...
So the question is... on a really crappy WAN is it possible for a java connection to have a connection that will never terminate? Assume for the moment that the "server" would normally always return and the network spans a very wide area network with all the associated problems (dropped connections).