Error connecting to HTTPS url: java.nio.channels.ClosedChannelException: null

2,754 views
Skip to first unread message

mark....@sigfig.com

unread,
Jul 13, 2015, 9:13:05 PM7/13/15
to asyncht...@googlegroups.com
I'm trying to use AsyncHttpClient + netty to POST to a HTTPS url (https://www.trademonster.com) , and I"m getting a mysterious "ClosedChannelException", but I'm really thinking its some sort of SSL error. I noticed that if I set 'setAcceptAnyCertificate" on the AsyncHttpClientConfig object, it connects fine, but without it it gets this exception.

I checked the java certificate store and it seems that it has the root CA that the certificate uses (Godaddy, godaddyrootg2ca, Jul 18, 2014, trustedCertEntry, Certificate fingerprint (SHA1): 47:BE:AB:C9:22:EA:E8:0E:78:78:34:62:A7:9F:45:C2:54:FD:E6:8B ), so I'm not sure why it can't successfully connect to this website when python+requests, firefox, chrome all can.

Full console log with -Djavax.net.debug="all": https://gist.github.com/anonymous/e3e3eb4238788baf5283

The exception text is here:

17:31:49 [Thread-3] ERROR c.s.s.AHCSession - Caught exception when trying to execute a http request: com.ning.http.client.AsyncHttpClient$BoundRequestBuilder@42aa444c
java.util.concurrent.ExecutionException: java.net.ConnectException: https://www.trademonster.com:443
    at com.ning.http.client.providers.netty.future.NettyResponseFuture.abort(NettyResponseFuture.java:231) ~[async-http-client-1.9.27.jar:na]
    at com.ning.http.client.providers.netty.request.NettyConnectListener.onFutureFailure(NettyConnectListener.java:135) ~[async-http-client-1.9.27.jar:na]
    at com.ning.http.client.providers.netty.request.NettyConnectListener.access$200(NettyConnectListener.java:37) ~[async-http-client-1.9.27.jar:na]
    at com.ning.http.client.providers.netty.request.NettyConnectListener$1.operationComplete(NettyConnectListener.java:104) ~[async-http-client-1.9.27.jar:na]
    at org.jboss.netty.channel.DefaultChannelFuture.notifyListener(DefaultChannelFuture.java:409) ~[netty-3.10.4.Final.jar:na]
    at org.jboss.netty.channel.DefaultChannelFuture.notifyListeners(DefaultChannelFuture.java:395) ~[netty-3.10.4.Final.jar:na]
Caused by: java.net.ConnectException: https://www.trademonster.com:443
    at com.ning.http.client.providers.netty.request.NettyConnectListener.onFutureFailure(NettyConnectListener.java:131) ~[async-http-client-1.9.27.jar:na]
    at com.ning.http.client.providers.netty.request.NettyConnectListener.access$200(NettyConnectListener.java:37) ~[async-http-client-1.9.27.jar:na]
    at com.ning.http.client.providers.netty.request.NettyConnectListener$1.operationComplete(NettyConnectListener.java:104) ~[async-http-client-1.9.27.jar:na]
    at org.jboss.netty.channel.DefaultChannelFuture.notifyListener(DefaultChannelFuture.java:409) ~[netty-3.10.4.Final.jar:na]
    at org.jboss.netty.channel.DefaultChannelFuture.notifyListeners(DefaultChannelFuture.java:395) ~[netty-3.10.4.Final.jar:na]
    at org.jboss.netty.channel.DefaultChannelFuture.setFailure(DefaultChannelFuture.java:362) ~[netty-3.10.4.Final.jar:na]
Caused by: java.nio.channels.ClosedChannelException: null
    at org.jboss.netty.handler.ssl.SslHandler.channelDisconnected(SslHandler.java:575) ~[netty-3.10.4.Final.jar:na]
    at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:102) ~[netty-3.10.4.Final.jar:na]
    at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564) ~[netty-3.10.4.Final.jar:na]
    at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:559) ~[netty-3.10.4.Final.jar:na]
    at org.jboss.netty.channel.Channels.fireChannelDisconnected(Channels.java:396) ~[netty-3.10.4.Final.jar:na]
    at org.jboss.netty.channel.socket.nio.AbstractNioWorker.close(AbstractNioWorker.java:360) ~[netty-3.10.4.Final.jar:na]

mark....@sigfig.com

unread,
Jul 13, 2015, 9:14:40 PM7/13/15
to asyncht...@googlegroups.com
As i forgot to mention, i'm using async-http-client 1.9.27 and netty 3.10.4-final

Stéphane LANDELLE

unread,
Jul 14, 2015, 2:47:21 AM7/14/15
to asyncht...@googlegroups.com

Stéphane Landelle
Lead developer


--
You received this message because you are subscribed to the Google Groups "asynchttpclient" group.
To unsubscribe from this group and stop receiving emails from it, send an email to asynchttpclie...@googlegroups.com.
To post to this group, send email to asyncht...@googlegroups.com.
Visit this group at http://groups.google.com/group/asynchttpclient.
For more options, visit https://groups.google.com/d/optout.

mark....@sigfig.com

unread,
Jul 14, 2015, 7:35:41 PM7/14/15
to asyncht...@googlegroups.com
Thank you for your quick reply and fix! I have confirmed that adding this to my AsyncHttpClientConfig:

builder.setEnabledProtocols(new String[] {"TLSv1.2", "TLSv1.1", "TLSv1"});

fixes the problem. I will also test the next release build once that comes out to make sure that it still works when you don't have those protocols set in the AsyncHttpClientConfig.

I'll mention this on github as well. Thanks again!

~Mark
Reply all
Reply to author
Forward
0 new messages