I have a client that connects to a server using SSLSocket. Next, I try to create an OOS with ObjectOutputStream oos = new ObjectOutputStream(sslsocket.getOutputStream());
If everything is working well on the server side, this is fine. However, I would like to put something in place on my client side that tries to create the ObjectOutputStream, but if it hasn't happened in 60 seconds, log the error and continue processing. I don't see any timeout options for this. Any examples of how this could be done?
SSLSocket sslsocket;
try {
System.setProperty("javax.net.ssl.trustStore", <myKeystore>);
System.setProperty("javax.net.ssl.trustStorePassword", <myPW>);
SSLSocketFactory sslsocketfactory = (SSLSocketFactory) SSLSocketFactory.getDefault();
sslsocket = (SSLSocket) sslsocketfactory.createSocket(InetAddress.getLocalHost(), <myPort>);
} catch (Throwable e) {
logger.logError(e.getMessage());
return null;
}
// This is where it hangs forever
ObjectOutputStream oos = new ObjectOutputStream(sslsocket.getOutputStream());
oos.flush(); // never gets here
oos.writeObject(orders);
ObjectInputStream ois = new ObjectInputStream(sslsocket.getInputStream());