/** * Template method for changing properties on the given {@link SocketChannelConfig}. * <p>The default implementation sets the connect timeout based on the set property. * @param config the channel configuration */ protected void configureChannel(SocketChannelConfig config) { if (this.connectTimeout >= 0) { config.setConnectTimeoutMillis(this.connectTimeout); } }
/** * Template method for changing properties on the given {@link SocketChannelConfig}. * <p>The default implementation sets the connect timeout based on the set property. * @param config the channel configuration */ protected void configureChannel(SocketChannelConfig config) { if (this.connectTimeout >= 0) { config.setConnectTimeoutMillis(this.connectTimeout); } }
@Override protected void initChannel(SocketChannel channel) throws Exception { ChannelPipeline pipeline = channel.pipeline(); if (params != null) { channel.config().setConnectTimeoutMillis( params.getConnectTimeout()); if (options != null) { channel.config().setOptions(options); } pipeline.addLast(new ReadTimeoutHandler(params .getReadTimeout(), TimeUnit.MILLISECONDS)); } pipeline.addLast(new HttpClientCodec()); pipeline.addLast(new HttpContentDecompressor()); pipeline.addLast(new ChunkedWriteHandler()); pipeline.addLast(new HttpResponseDecoder()); pipeline.addLast(new HttpObjectAggregator( Integer.MAX_VALUE)); } });
/** * Template method for changing properties on the given {@link SocketChannelConfig}. * <p>The default implementation sets the connect timeout based on the set property. * @param config the channel configuration */ protected void configureChannel(SocketChannelConfig config) { if (this.connectTimeout >= 0) { config.setConnectTimeoutMillis(this.connectTimeout); } }
/** * Template method for changing properties on the given {@link SocketChannelConfig}. * <p>The default implementation sets the connect timeout based on the set property. * @param config the channel configuration */ protected void configureChannel(SocketChannelConfig config) { if (this.connectTimeout >= 0) { config.setConnectTimeoutMillis(this.connectTimeout); } }
/** * Template method for changing properties on the given {@link SocketChannelConfig}. * <p>The default implementation sets the connect timeout based on the set property. * @param config the channel configuration */ protected void configureChannel(SocketChannelConfig config) { if (this.connectTimeout >= 0) { config.setConnectTimeoutMillis(this.connectTimeout); } }
@Override public void connect(SocketAddress endpoint, int timeout) throws IOException { ch.config().setConnectTimeoutMillis(timeout); ch.connect(endpoint).syncUninterruptibly(); }
@Override protected void initChannel(SocketChannel channel) throws Exception { ChannelPipeline pipeline = channel.pipeline(); if (params != null) { channel.config().setConnectTimeoutMillis( params.getConnectTimeout()); if (options != null) { channel.config().setOptions(options); } pipeline.addLast(new ReadTimeoutHandler(params .getReadTimeout(), TimeUnit.MILLISECONDS)); } pipeline.addLast(new HttpClientCodec()); pipeline.addLast(new HttpContentDecompressor()); pipeline.addLast(new ChunkedWriteHandler()); pipeline.addLast(new HttpResponseDecoder()); pipeline.addLast(new HttpObjectAggregator( Integer.MAX_VALUE)); } });
@Override public void initChannel(final SocketChannel ch) throws Exception { ch.config().setConnectTimeoutMillis(options.timeout()); if (null != sslOptions) { SSLEngine ssl = new SSLEngineSupplier(sslOptions, true).get(); if (log.isDebugEnabled()) { log.debug("SSL enabled using keystore {}", (null != sslOptions.keystoreFile() ? sslOptions.keystoreFile() : "<DEFAULT>")); } ch.pipeline().addLast(new SslHandler(ssl)); } if (null != nettyOptions && null != nettyOptions.pipelineConfigurer()) { nettyOptions.pipelineConfigurer().accept(ch.pipeline()); } ch.pipeline().addLast(createChannelHandlers(ch)); } });
@Override public void initChannel(final SocketChannel ch) throws Exception { ch.config().setConnectTimeoutMillis(options.timeout()); if(null != sslOpts) { SSLEngine ssl = new SSLEngineSupplier(sslOpts, true).get(); log.debug("SSL enabled using keystore {}", (null != sslOpts.keystoreFile() ? sslOpts.keystoreFile() : "<DEFAULT>")); ch.pipeline().addLast(new SslHandler(ssl)); } if(options instanceof NettyClientSocketOptions && null != ((NettyClientSocketOptions)options) .pipelineConfigurer()) { ((NettyClientSocketOptions)options).pipelineConfigurer().accept(ch.pipeline()); } ch.pipeline().addLast(createChannelHandlers(ch)); ch.closeFuture().addListener(new ChannelFutureListener() { @Override public void operationComplete(ChannelFuture future) throws Exception { connections.remove(ch); } }); } });
@Override public void initChannel(final SocketChannel ch) throws Exception { ch.config().setConnectTimeoutMillis(getOptions().timeout()); if (null != getSslOptions()) { addSecureHandler(ch); } else { ch.config().setAutoRead(false); } if (null != nettyOptions && null != nettyOptions.pipelineConfigurer()) { nettyOptions.pipelineConfigurer().accept(ch.pipeline()); } bindChannel(targetHandler, ch); } });