문제

How can use netty websocket client with wss?

Now I need one websocket client, I find one websocket example (https://github.com/netty/netty/blob/master/example/src/main/java/io/netty/example/http/websocketx/client/WebSocketClient.java) in netty , but it only support ws. Who could provide one websocket client example which support wss?

Who can help me ?

Thanks

Jose


Thanks

I put the SslHandler as the first hander in the ChannelPipeline now

 SSLEngine sslEngine = SSLContextProvider.get().createSSLEngine();
 sslEngine.setUseClientMode(true);
 pipeline.addLast("ssl", new SslHandler(sslEngine));

Then run the WebSocketClient in example to connect one websocket server with wss, get one error:

WebSocket Client sending message
java.lang.ClassCastException: io.netty.handler.codec.http.websocketx.TextWebSocketFrame cannot be cast to io.netty.buffer.ByteBuf
    at io.netty.handler.ssl.SslHandler.write(SslHandler.java:389)
    at io.netty.channel.DefaultChannelHandlerContext.invokeWrite0(DefaultChannelHandlerContext.java:716)
    at io.netty.channel.DefaultChannelHandlerContext.access$26(DefaultChannelHandlerContext.java:713)
    at io.netty.channel.DefaultChannelHandlerContext$18.run(DefaultChannelHandlerContext.java:705)
    at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:353)
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:365)
    at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:101)
    at java.lang.Thread.run(Unknown Source)

How to fix it?

올바른 솔루션이 없습니다

다른 팁

Just put the SslHandler as the first hander in the ChannelPipeline. That's all.

Just follow the netty websocket client example in Github Netty client example with WSS/WS

Just change the URL from ws to wss

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top