Duplicate "ssl" Handlers Error in DefaultChannelPipeline

99 views
Skip to first unread message

Phuoc Huynh

unread,
Dec 19, 2014, 2:14:43 PM12/19/14
to littl...@googlegroups.com
Hello,

First of all, thank you for the great work you have done on this project. 

I have tried searching for the problem but couldn't find anything on it, so it must be particular to my situation. Any help would be greatly appreciated. Thank you in advance!

Here is my situation:

My application is running on a restricted server that only has port 443 open to public. However, the application was initially designed to be ran on a server that has a range of ports open, so it could instantiate a Littleshoot proxy (RealProxy) on each port and make multiple connections simultaneously.

Thus, I tried to improvise by placing another Littleshoot proxy (a RoutingProxy), in between the client and the RealProxy(s), that does all the port handling and routing to the correct RealProxy with some port information sent by the client. 

It looks something like this:

 /---------> RealProxy 1 --------> SERVER 1
CLIENT --> RoutingProxy --/----------> RealProxy 2 ------- > SERVER 2
\----------> RealProxy 3 --------> SERVER 3
.....                         ..... 

At first, everything seems to be working just fine. However, once in a while, I get this error:

41724  2014-12-19 11:09:07,633 WARN  [LittleProxy-ClientToProxyWorker-7] concurrent.DefaultPromise.? (?:?) - An exception was thrown by org.littleshoot.proxy.impl.ConnectionFlow$2.operationComplete()
java.lang.IllegalArgumentException: Duplicate handler name: ssl
at io.netty.channel.DefaultChannelPipeline.checkDuplicateName(DefaultChannelPipeline.java:898)
at io.netty.channel.DefaultChannelPipeline.addFirst(DefaultChannelPipeline.java:98)
at io.netty.channel.DefaultChannelPipeline.addFirst(DefaultChannelPipeline.java:92)
at org.littleshoot.proxy.impl.ProxyConnection.encrypt(ProxyConnection.java:378)
at org.littleshoot.proxy.impl.ProxyConnection.encrypt(ProxyConnection.java:355)
at org.littleshoot.proxy.impl.ProxyToServerConnection$3.execute(ProxyToServerConnection.java:603)
at org.littleshoot.proxy.impl.ConnectionFlow.doProcessCurrentStep(ConnectionFlow.java:139)
at org.littleshoot.proxy.impl.ConnectionFlow.processCurrentStep(ConnectionFlow.java:128)
at org.littleshoot.proxy.impl.ConnectionFlow.advance(ConnectionFlow.java:90)
at org.littleshoot.proxy.impl.ConnectionFlowStep.onSuccess(ConnectionFlowStep.java:83)
at org.littleshoot.proxy.impl.ConnectionFlow$2.operationComplete(ConnectionFlow.java:147)
at io.netty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:621)
at io.netty.util.concurrent.DefaultPromise.notifyListener(DefaultPromise.java:598)
at io.netty.util.concurrent.DefaultPromise.addListener(DefaultPromise.java:123)
at io.netty.channel.DefaultChannelPromise.addListener(DefaultChannelPromise.java:93)
at io.netty.channel.DefaultChannelPromise.addListener(DefaultChannelPromise.java:28)
at org.littleshoot.proxy.impl.ConnectionFlow.doProcessCurrentStep(ConnectionFlow.java:139)
at org.littleshoot.proxy.impl.ConnectionFlow.access$000(ConnectionFlow.java:14)
at org.littleshoot.proxy.impl.ConnectionFlow$1.run(ConnectionFlow.java:124)
at io.netty.util.concurrent.PromiseTask$RunnableAdapter.call(PromiseTask.java:38)
at io.netty.util.concurrent.PromiseTask.run(PromiseTask.java:73)
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:354)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:353)
at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:101)
at java.lang.Thread.run(Thread.java:744)

Then any connections made afterward are dropped. Any idea why this might be happening?

Here is essentially the code that I use to start both my RoutingProxy and RealProxy:

if (isRunning()) {
            throw new IllegalStateException("Routing proxy server is already running");
        }

        InetSocketAddress address = new InetSocketAddress(proxyConfiguration.getProxyHost(), proxyConfiguration.getProxyPort());
        LOG.info(String.format("Routing proxy server is binding to %s", address));
        HttpProxyServerBootstrap proxyServerBootstrap = DefaultHttpProxyServer
                .bootstrap()
                .withIdleConnectionTimeout(proxyConfiguration.getProxyTimeoutSeconds())
                .withAddress(address);

        if (proxyConfiguration.isSslEnabled()) {
            proxyServerBootstrap.withManInTheMiddle(new SelfSignedMitmManager());
        } else {
            proxyServerBootstrap.withChainProxyManager(proxyOverrider);
        }

        proxyServerBootstrap.withFiltersSource(new HttpFiltersSourceAdapter() {
            @Override
            public int getMaximumRequestBufferSizeInBytes() {
                return proxyConfiguration.getRequestBufferSize();
            }

            @Override
            public HttpFilters filterRequest(HttpRequest originalRequest) {
                RequestFilters requestFilters = new RequestFilters(originalRequest);
                return new PredicatedHttpFilters(requestFilters, NOT_CONNECT, originalRequest);
            }
        });

        proxyServer = proxyServerBootstrap.start();
        running = true;

        overrideProxySettings();
        overrideSSLSettings();
}

Thank you!



Phuoc Huynh

unread,
Jan 5, 2015, 12:04:06 PM1/5/15
to littl...@googlegroups.com
A little bump after the holidays break. Happy Holidays to everyone!
Reply all
Reply to author
Forward
0 new messages