1

我正在尝试使用带有代理服务器配置的 AsyncHttpClient 来使用 wss 进行连接,但没有运气。我一直在使用 async-http-client 1.7.5 和 grizzly-websockets 2.2.13 我的第一次尝试

AsyncHttpClientConfig config = new AsyncHttpClientConfig.Builder()
        .setSSLContext(sc)
        .setProxyServer(
        new ProxyServer(Protocol.HTTP, "192.168.1.130", 3128))
        .build();
NettyWebSocket w = (NettyWebSocket)c.prepareGet("wss://192.168.1.124/atmosphere-chat/chat")
        .execute(handler).get();

使用默认的 netty 配置无法正常工作,此尝试似乎至少通过代理并连接到远程服务器。我得到的例外是

java.lang.IllegalArgumentException: unsupported message type: class org.jboss.netty.handler.codec.http.websocketx.TextWebSocketFrame

当我切换到使用 grizzly 时

AsyncHttpClient c = new AsyncHttpClient(new GrizzlyAsyncHttpProvider(config), config);

事情变得更好/更糟。在这种情况下,grizzly 似乎无法通过 http 代理发送连接动词,并立即开始通过 ssl 进行通信,但失败了。我认为这将是一个得到很好支持的情况,因为在使用 SSL 时 websocket 连接将通过代理工作的可能性增加。]

Exception in thread "main" java.util.concurrent.ExecutionException: javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?

我是否超出了应该工作的范围?

4

1 回答 1

1

原来这是 AHC 中的一个错误(https://github.com/sonatype/async-http-client/issues/131#issuecomment-7745037)在 1.8.0 中得到修复。

于 2012-08-29T01:23:07.490 回答