ning / async-http-client

Asynchronous Http Client for Java
135 stars 50 forks source link

Ning AHC: Secured Grizzly Websocket is not connecting through squid proxy #53

Open manikandar opened 11 years ago

manikandar commented 11 years ago

With Grizzly provider, I could able to connect websocket through proxy. But when I try to set SSLContext to the client, it starting throwing exception:

javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection? at org.glassfish.grizzly.ssl.SSLUtils.getSSLPacketSize(SSLUtils.java:172) at org.glassfish.grizzly.ssl.SSLUtils.handshakeUnwrap(SSLUtils.java:203) at org.glassfish.grizzly.ssl.SSLFilter.doHandshakeStep(SSLFilter.java:327) at org.glassfish.grizzly.ssl.SSLFilter.handleRead(SSLFilter.java:177) at com.ning.http.client.providers.grizzly.GrizzlyAsyncHttpProvider$SwitchingSSLFilter.handleRead(GrizzlyAsyncHttpProvider.java:2532) at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119) at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:265) at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:200) at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:134) at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112) at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:78) at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:770) at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112) at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:115) at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:55) at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:135) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:662)

The Squid Proxy access log is showing the following request log line: 1356520015.018 0 192.168.125.1 NONE/400 3501 �e - NONE/- text/html Note the binary data in the request line.

Notes:

  1. Websocket connection through Proxy is working fine.
  2. Secured Websocket connection with the same SSLContext with out any proxy is working fine.
  3. Secured Websocket connection with the same SSLContext through proxy is not working.

Posted this issue in the forum and was asked to create issue for the same: https://groups.google.com/d/msg/asynchttpclient/-/FvoakS5P3OwJ.

manikandar commented 11 years ago

Squid Proxy Configuration used:

acl manager proto cache_object acl localhost src 127.0.0.1/32 ::1 acl to_localhost dst 127.0.0.0/8 0.0.0.0/32 ::1 acl SSL_ports port 443 acl SSL_ports port 8080 acl Safe_ports port 80 # http acl Safe_ports port 21 # ftp acl Safe_ports port 443 # https acl Safe_ports port 70 # gopher acl Safe_ports port 210 # wais acl Safe_ports port 1025-65535 # unregistered ports acl Safe_ports port 280 # http-mgmt acl Safe_ports port 488 # gss-http acl Safe_ports port 591 # filemaker acl Safe_ports port 777 # multiling http acl Safe_ports port 8080 acl CONNECT method CONNECT http_access allow manager localhost http_access deny manager http_access deny !Safe_ports http_access deny CONNECT !SSL_ports http_access allow localhost http_access allow all http_port 3128 hierarchy_stoplist cgi-bin ? coredump_dir /var/spool/squid3 refresh_pattern ^ftp: 1440 20% 10080 refresh_pattern ^gopher: 1440 0% 1440 refresh_pattern -i (/cgi-bin/|\?) 0 0% 0 refresh_pattern . 0 20% 4320