Reconnection fixed

pull/6/head
Nikita 11 years ago
parent 2b06ca4778
commit f653854006

@ -3,6 +3,7 @@
package com.lambdaworks.redis.protocol;
import com.lambdaworks.redis.RedisAsyncConnection;
import io.netty.bootstrap.Bootstrap;
import io.netty.channel.*;
import io.netty.channel.group.ChannelGroup;
@ -79,6 +80,20 @@ public class ConnectionWatchdog extends ChannelInboundHandlerAdapter implements
*/
@Override
public void run(Timeout timeout) throws Exception {
bootstrap.connect();
ChannelPipeline old = channel.pipeline();
final CommandHandler<?, ?> handler = old.get(CommandHandler.class);
final RedisAsyncConnection<?, ?> connection = old.get(RedisAsyncConnection.class);
ChannelFuture connect = null;
// TODO use better concurrent workaround
synchronized (bootstrap) {
connect = bootstrap.handler(new ChannelInitializer<Channel>() {
@Override
protected void initChannel(Channel ch) throws Exception {
ch.pipeline().addLast(this, handler, connection);
}
}).connect();
}
connect.sync();
}
}

Loading…
Cancel
Save