I’m using Apache Thrift server written on Java. When i’m create ServerSocket i’m pass a parameter called clientTimeout with value 60000 (ten minutes). But this not work as expected – i’m connect to server, execute a method wait 11 minutes execute method again without reconnect and didn’t get error (as i’m expected).
I’m try do it on not SSL thrift server, this work fine.
In thrift sources i’m found how to SSL socket created, seems ok.
private static TServerSocket createServer(SSLServerSocketFactory factory, int port, int timeout, boolean clientAuth,
InetAddress ifAddress, TSSLTransportParameters params) throws TTransportException {
try {
SSLServerSocket serverSocket = (SSLServerSocket) factory.createServerSocket(port, 100, ifAddress);
serverSocket.setSoTimeout(timeout);
serverSocket.setNeedClientAuth(clientAuth);
if (params != null && params.cipherSuites != null) {
serverSocket.setEnabledCipherSuites(params.cipherSuites);
}
return new TServerSocket(serverSocket);
} catch (Exception e) {
throw new TTransportException("Could not bind to port " + port, e);
}
}
has anyone such problem? How to fix it?
The timeout on a
ServerSocketaffectsServerSocket.accept()only.It is not inherited by acceptedSocketsas a read timeout. If you want that, you have to set it explicitly. This is a difference between the Java API and the BSD Sockets API.