SSL Socket connect timeout

With java 1.7 the following does not throw the exception stated in the question:

String host = "example.com";
int port = 12345;
int connectTimeout = 5000;
SSLSocket socket = (SSLSocket)SSLSocketFactory.getDefault().createSocket();
socket.connect(new InetSocketAddress(host, port), connectTimeout);
socket.startHandshake();

so it's business as usual.


I believe you could use your current approach of creating the Socket and then connecting it. To establish SSL over the connection you could use SSLSocketFactory.createSocket

Returns a socket layered over an existing socket connected to the named host, at the given port.

This way you get full control over the connection and then you negociate setting up SSL on top of it. Please let me know if I misread your question.