Merge pull request #199 from sehugg/jedis
--- The subscribe and psubscribe operations call setTimeoutInfinite() since they never return on their own. If the Redis server goes away without closing the connection, the connection can hang indefinitely. Turning on keep-alive will allow the connection to eventually timeout and attempt reconnection. Note that keepalive must also be enabled on your server, see the Linux HOWTOs on how to do this.
This commit is contained in:
@@ -38,6 +38,7 @@ public class Connection {
|
||||
|
||||
public void setTimeoutInfinite() {
|
||||
try {
|
||||
socket.setKeepAlive(true);
|
||||
socket.setSoTimeout(0);
|
||||
} catch (SocketException ex) {
|
||||
throw new JedisException(ex);
|
||||
@@ -47,6 +48,7 @@ public class Connection {
|
||||
public void rollbackTimeout() {
|
||||
try {
|
||||
socket.setSoTimeout(timeout);
|
||||
socket.setKeepAlive(false);
|
||||
} catch (SocketException ex) {
|
||||
throw new JedisException(ex);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user