import org.opendaylight.ovsdb.lib.OvsdbConnection;
import org.opendaylight.ovsdb.lib.OvsdbConnectionInfo.ConnectionType;
import org.opendaylight.ovsdb.lib.OvsdbConnectionListener;
+import org.opendaylight.ovsdb.lib.jsonrpc.ExceptionHandler;
import org.opendaylight.ovsdb.lib.jsonrpc.JsonRpcDecoder;
import org.opendaylight.ovsdb.lib.jsonrpc.JsonRpcEndpoint;
import org.opendaylight.ovsdb.lib.jsonrpc.JsonRpcServiceBinderHandler;
channel.pipeline().addLast(
//new LoggingHandler(LogLevel.INFO),
new JsonRpcDecoder(100000),
- new StringEncoder(CharsetUtil.UTF_8));
+ new StringEncoder(CharsetUtil.UTF_8),
+ new ExceptionHandler());
}
});
logger.debug("New Passive channel created : "+ channel.toString());
channel.pipeline().addLast(
new JsonRpcDecoder(100000),
- new StringEncoder(CharsetUtil.UTF_8));
+ new StringEncoder(CharsetUtil.UTF_8),
+ new ExceptionHandler());
handleNewPassiveConnection(channel);
}
import io.netty.handler.codec.TooLongFrameException;
import org.opendaylight.ovsdb.lib.error.InvalidEncodingException;
+import java.io.IOException;
+
public class ExceptionHandler extends ChannelHandlerAdapter {
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
if ((cause instanceof InvalidEncodingException)
- || (cause instanceof TooLongFrameException)) {
-
+ || (cause instanceof TooLongFrameException)){
ctx.channel().disconnect();
}
+ /* In cases where a connection is quickly established and the closed
+ Catch the IOException and close the channel
+ */
+ if (cause instanceof IOException){
+ ctx.channel().close();
+ }
}
}