Proxy based http connections do not throw Proxy errors

825 views
Skip to first unread message

Pavan Kumar

unread,
Jul 4, 2016, 4:08:11 AM7/4/16
to vert.x
I have an application where HTTP requests are initiated via a HTTP proxy. It seems to be working well when connections succeed, but during proxy failures(502, 403 etc from proxy), the Vertx (3.3.0) fails to report the failure and my application keeps waiting for the response. Luckily, Netty logs make it clear about the issue, but the application does not receive an event. This event would help as we may expect alternate proxy servers and the application can try the next in queue if one reports an error.

Below is from Netty stack trace:

[vert.x-eventloop-thread-2] WARN  i.n.channel.DefaultChannelPipeline - An exceptionCaught() event was fired, and it reached at the tail of the pipeline. It usually means the last handler in the pipeline did not handle the exception.
io.netty.handler.proxy.ProxyConnectException: http, none, localhost/127.0.0.1:3128 => target-server:8080, status: 403 Forbidden
    at io.netty.handler.proxy.HttpProxyHandler.handleResponse(HttpProxyHandler.java:155) ~[netty-handler-proxy-4.1.1.Final.jar:4.1.1.Final]
    at io.netty.handler.proxy.ProxyHandler.channelRead(ProxyHandler.java:259) ~[netty-handler-proxy-4.1.1.Final.jar:4.1.1.Final]
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [netty-transport-4.1.1.Final.jar:4.1.1.Final]
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:334) [netty-transport-4.1.1.Final.jar:4.1.1.Final]
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:326) [netty-transport-4.1.1.Final.jar:4.1.1.Final]
    at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:428) [netty-transport-4.1.1.Final.jar:4.1.1.Final]
    at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:293) [netty-codec-4.1.1.Final.jar:4.1.1.Final]
    at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:267) [netty-codec-4.1.1.Final.jar:4.1.1.Final]
    at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:243) [netty-transport-4.1.1.Final.jar:4.1.1.Final]
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [netty-transport-4.1.1.Final.jar:4.1.1.Final]
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:334) [netty-transport-4.1.1.Final.jar:4.1.1.Final]
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:326) [netty-transport-4.1.1.Final.jar:4.1.1.Final]
    at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1320) [netty-transport-4.1.1.Final.jar:4.1.1.Final]
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [netty-transport-4.1.1.Final.jar:4.1.1.Final]
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:334) [netty-transport-4.1.1.Final.jar:4.1.1.Final]
    at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:905) [netty-transport-4.1.1.Final.jar:4.1.1.Final]
    at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:123) [netty-transport-4.1.1.Final.jar:4.1.1.Final]
    at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:563) [netty-transport-4.1.1.Final.jar:4.1.1.Final]
    at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:504) [netty-transport-4.1.1.Final.jar:4.1.1.Final]
    at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:418) [netty-transport-4.1.1.Final.jar:4.1.1.Final]
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:390) [netty-transport-4.1.1.Final.jar:4.1.1.Final]
    at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:742) [netty-common-4.1.1.Final.jar:4.1.1.Final]
    at java.lang.Thread.run(Thread.java:745) [na:1.8.0_74]


Let me know if I missed anything / any workarounds / if an issue need to be raised.

Julien Viet

unread,
Jul 4, 2016, 4:50:44 AM7/4/16
to ve...@googlegroups.com
Hi,

can you provide a reproducer, so it can be examined and fixed in the upcoming 3.3.1 ?


--
You received this message because you are subscribed to the Google Groups "vert.x" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vertx+un...@googlegroups.com.
Visit this group at https://groups.google.com/group/vertx.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/494f5a1c-cd26-440c-b1a7-52bd8e349d80%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Pavan Kumar

unread,
Jul 4, 2016, 6:48:22 AM7/4/16
to vert.x
Here is the reproducer.

public static void main(String[] args) {
        Vertx vertx = Vertx.vertx();
        HttpClientOptions options = new HttpClientOptions();
        ProxyOptions proxyOptions = new ProxyOptions();
        proxyOptions.setHost("www.google.com");
        proxyOptions.setPort(80);
        options.setProxyOptions(proxyOptions);
        HttpClient client = vertx.createHttpClient(options);
       
        client.getAbs("http://vertx.io/", resp ->
            System.out.println(resp.getHeader("Content-Length")))
            .exceptionHandler(e -> System.out.println("Got error: "+e.getMessage()))
            .end();
       
        try {
            new CountDownLatch(2).await();
        } catch (InterruptedException e) {   }

Alexander Lehmann

unread,
Jul 4, 2016, 6:52:20 AM7/4/16
to vert.x
I may be able to implement a few unit tests checking the issue (and then hopefully fix it), could you please create an issue on the eclipse/vert.x github tracker?

Alexander Lehmann

unread,
Jul 4, 2016, 6:52:57 AM7/4/16
to vert.x
Thank you, I will take a look

Pavan Kumar

unread,
Jul 4, 2016, 7:17:22 AM7/4/16
to vert.x
Thank you. Here is the issue: https://github.com/eclipse/vert.x/issues/1489
Reply all
Reply to author
Forward
0 new messages