List of usage examples for io.netty.channel ChannelOption AUTO_READ
ChannelOption AUTO_READ
To view the source code for io.netty.channel ChannelOption AUTO_READ.
Click Source Link
From source file:com.github.jrialland.ajpclient.pool.Channels.java
License:Apache License
public static Bootstrap newBootStrap(final String host, final int port, final EventLoopGroup eventLoopGroup) { return new Bootstrap().group(getEventLoopGroup()).remoteAddress(host, port).channel(NioSocketChannel.class) .option(ChannelOption.SO_KEEPALIVE, true).option(ChannelOption.AUTO_READ, true); }
From source file:com.gxkj.demo.netty.proxy.HexDumpProxy.java
License:Apache License
public void run() throws Exception { System.err.println("Proxying *:" + localPort + " to " + remoteHost + ':' + remotePort + " ..."); // Configure the bootstrap. EventLoopGroup bossGroup = new NioEventLoopGroup(); EventLoopGroup workerGroup = new NioEventLoopGroup(); try {// w ww . j a v a2s . co m ServerBootstrap b = new ServerBootstrap(); b.group(bossGroup, workerGroup).channel(NioServerSocketChannel.class) .childHandler(new HexDumpProxyInitializer(remoteHost, remotePort)) .childOption(ChannelOption.AUTO_READ, false).bind(localPort).sync().channel().closeFuture() .sync(); } finally { bossGroup.shutdownGracefully(); workerGroup.shutdownGracefully(); } }
From source file:com.gxkj.demo.netty.proxy.HexDumpProxyFrontendHandler.java
License:Apache License
@Override public void channelActive(ChannelHandlerContext ctx) throws Exception { final Channel inboundChannel = ctx.channel(); // Start the connection attempt. Bootstrap b = new Bootstrap(); b.group(inboundChannel.eventLoop()).channel(ctx.channel().getClass()) .handler(new HexDumpProxyBackendHandler(inboundChannel)).option(ChannelOption.AUTO_READ, false); ChannelFuture f = b.connect(remoteHost, remotePort); outboundChannel = f.channel();/*from ww w.j av a 2 s . c o m*/ f.addListener(new ChannelFutureListener() { @Override public void operationComplete(ChannelFuture future) throws Exception { if (future.isSuccess()) { // connection complete start to read first data inboundChannel.read(); } else { // Close the connection if the connection attempt has failed. inboundChannel.close(); } } }); }
From source file:com.hop.hhxx.example.proxy.HexDumpProxyFrontendHandler.java
License:Apache License
@Override public void channelActive(ChannelHandlerContext ctx) { final Channel inboundChannel = ctx.channel(); // Start the connection attempt. Bootstrap b = new Bootstrap(); b.group(inboundChannel.eventLoop()).channel(ctx.channel().getClass()) .handler(new io.netty.example.proxy.HexDumpProxyBackendHandler(inboundChannel)) .option(ChannelOption.AUTO_READ, false); ChannelFuture f = b.connect(remoteHost, remotePort); outboundChannel = f.channel();/*from w w w.j a va 2 s. c om*/ f.addListener(new ChannelFutureListener() { @Override public void operationComplete(ChannelFuture future) { if (future.isSuccess()) { // connection complete start to read first data inboundChannel.read(); } else { // Close the connection if the connection attempt has failed. inboundChannel.close(); } } }); }
From source file:com.hxr.javatone.concurrency.netty.official.proxy.HexDumpProxyFrontendHandler.java
License:Apache License
@Override public void channelActive(ChannelHandlerContext ctx) throws Exception { final Channel inboundChannel = ctx.channel(); // Start the connection attempt. Bootstrap b = new Bootstrap(); b.group(inboundChannel.eventLoop()).channel(ctx.channel().getClass()) .handler(new HexDumpProxyBackendHandler(inboundChannel)).option(ChannelOption.AUTO_READ, false); ChannelFuture f = b.connect(remoteHost, remotePort); outboundChannel = f.channel();//from w ww . j a va 2 s .c o m f.addListener(new ChannelFutureListener() { @Override public void operationComplete(ChannelFuture future) throws Exception { if (future.isSuccess()) { // connection complete start to read first data inboundChannel.read(); } else { // Close the connection if the connection attempt has failed. inboundChannel.close(); } } }); }
From source file:com.jt.flash.proxy.handler.ProxyFrontendHandler.java
License:Apache License
private Bootstrap buildBackendBootstrap(ChannelHandlerContext ctx, final Channel inboundChannel, final int port) { Bootstrap b = new Bootstrap().group(inboundChannel.eventLoop()).channel(ctx.channel().getClass()) .option(ChannelOption.AUTO_READ, false).handler(new BackendInitChannel(port, inboundChannel)); return b;/* w ww . j ava 2 s. c om*/ }
From source file:com.jt.flash.proxy.server.ProxyServer.java
License:Apache License
public void start() { try {/*www .j a v a2s . co m*/ log.info("Proxying server start at port {}", upstreamPort); SelfSignedCertificate ssc = new SelfSignedCertificate(); SslContext sslCtx = SslContextBuilder.forServer(ssc.certificate(), ssc.privateKey()).build(); ConfigService.reload(configDao.loadLastest()); ServerBootstrap b = new ServerBootstrap(); channel = b.group(proxyServerBossGroup, proxyServerWorkerGroup).channel(NioServerSocketChannel.class) .childOption(ChannelOption.AUTO_READ, false).handler(new LoggingHandler(LogLevel.DEBUG)) .childHandler(new ProxyInitializer(sslCtx)).bind(upstreamPort).channel(); } catch (Exception e) { log.warn("start proxy server fail", e); } }
From source file:com.mattrjacobs.hystrix.server.rs.ExampleServer.java
License:Apache License
public ExampleServer(final int port) { rsServer = ReactiveSocketWebSocketServer.create(setupPayload -> new ExampleServerHandler()); server = HttpServer.newServer(port).clientChannelOption(ChannelOption.AUTO_READ, true) .enableWireLogging(LogLevel.INFO); }
From source file:com.netty.grpc.proxy.demo.handler.GrpcProxyFrontendHandler.java
License:Apache License
@Override public void channelActive(ChannelHandlerContext ctx) { final Channel inboundChannel = ctx.channel(); // ??// ww w .j ava 2 s. c om Bootstrap b = new Bootstrap(); b.group(inboundChannel.eventLoop()).channel(ctx.channel().getClass()) .handler(new GrpcProxyBackendHandler(inboundChannel)).option(ChannelOption.AUTO_READ, false); for (int i = 0; i < remoteHosts.length; i++) { final ChannelFuture f = b.connect(remoteHosts[i], remotePorts[i]); outboundChannels[i] = f.channel(); f.addListener(new ChannelFutureListener() { public void operationComplete(ChannelFuture future) { if (future.isSuccess()) { // connection complete start to read first data inboundChannel.read(); // System.out.println(f.channel().remoteAddress() + ", " + f.channel().localAddress()); } else { // Close the connection if the connection attempt has failed. // System.out.println("channelActive close" + inboundChannel.remoteAddress() + ", " + inboundChannel.localAddress()); inboundChannel.close(); } } }); } }
From source file:com.netty.grpc.proxy.demo.start.ProxyStarter.java
License:Apache License
public static void main(String[] args) throws Exception { // Configure the bootstrap. EventLoopGroup bossGroup = new NioEventLoopGroup(1); EventLoopGroup workerGroup = new NioEventLoopGroup(); AtomicInteger counter = new AtomicInteger(0); try {//from w w w.ja v a 2s . c o m ServerBootstrap b = new ServerBootstrap(); b.group(bossGroup, workerGroup).channel(NioServerSocketChannel.class) .handler(new LoggingHandler(LogLevel.INFO)) .childHandler(new GrpcProxyInitializer(remote_hosts, remote_ports, counter)) .childOption(ChannelOption.AUTO_READ, false).bind(LOCAL_PORT).sync().channel().closeFuture() .sync(); } finally { bossGroup.shutdownGracefully(); workerGroup.shutdownGracefully(); } }