Example usage for io.netty.handler.proxy ProxyHandler setConnectTimeoutMillis

List of usage examples for io.netty.handler.proxy ProxyHandler setConnectTimeoutMillis

Introduction

In this page you can find the example usage for io.netty.handler.proxy ProxyHandler setConnectTimeoutMillis.

Prototype

public final void setConnectTimeoutMillis(long connectTimeoutMillis) 

Source Link

Document

Sets the connect timeout in millis.

Usage

From source file:com.github.sinsinpub.pero.backend.ConnectBackendHandler.java

License:Apache License

/**
 * Create new instance of proxy handler as it is not Sharable.
 * /* www .  jav  a 2s  .c om*/
 * @return Socks5ProxyHandler
 */
protected ProxyHandler newUpstreamProxyHandler(int index) {
    final ProxyHandler upstreamProxyHandler;
    final StringBuilder attrPrefix = new StringBuilder("upstream.socks5.");
    if (index > 0) {
        attrPrefix.append(String.valueOf(index)).append(".");
    }
    String host = AppProps.PROPS.getValue(attrPrefix.toString().concat("host"));
    if (StringUtil.isEmpty(host)) {
        upstreamProxyHandler = null;
    } else {
        int port = AppProps.PROPS.getInteger(attrPrefix.toString().concat("port"), 1080);
        upstreamProxyHandler = new Socks5ProxyHandler(new InetSocketAddress(host, port));
        upstreamProxyHandler.setConnectTimeoutMillis(getConnectTimeoutMillis());
    }
    return upstreamProxyHandler;
}