How can use netty websocket client with wss? - websocket
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
Related
How to send response back from server to client using Apache camel netty , spring boot
I have two modules as client and server. I am currently sending echo messages from client to server using netty server routes from(netty:tcp://0.0.0.0:21005). Now the message is getting send to server but how to send response back from server to client. Is it possible using same route. Any help much appreciated. Thanks in advance.
Configure connection for a direct exchange in Spring Boot AMQP
I'm developing a service that sends messages to a RabbitMQ instance but the connectino has to be done through a proxy. Is there a way to configure the connection so I can set up the host and port of the proxy as you can do when using RestTemplate but for RabbitTemplate? Any help would be really appreciated, Regards
when do sockjs fallback to xhr streaming transport instead of websocket
I have a simple web app, which is using websockets. simple webapp: Frontend - using sockjs, stomp Backend - Spring 4.2.x Frontend & Backend are packaged in the same WAR, this WAR is deployed on IBM WebSphere Application Server v9.x When I check the Developer Tools/Web Console in chrome(61.x)/firefox(56.0, 32 bit), I see that websocket transport is not being used, it's always xhr streaming. To use the websocket transport, I have passed the transports option in sockjs, like below, but after this change the websockets stopped working. var sockjs = new SockJS(my url, null, {transports: ["websocket"]}); Do we need to change any configuration on IBM WebSphere Application Server v9.x to enable websocket transport ? Update: on tomcat/liberty servers, sample app always uses websocket transport. Only on WAS, it is using xhr streaming. Issue in WAS?
Websocket protocol handling is on by default for Websphere v9.x
Any websocket error codes simulator available to test java websocket client for different websocket errors that can come
I have a STOMP over websocket client server implementation. I want to test my java websocket client implemented using javax websocket on eclipse jetty for different websocket errors that can come. Is there a websocket simulator that can send different websocket error codes that I wish to test ? My websocket server is implemented using spring websockets.
ActiveMQ failover for stomp over websocket
Is there a workaround to implement an activemq failover for stomp over websocket? The uri in my web browser is ws://localhost:61614/stomp which is working fine. But adding failover:(ws://localhost:61614/stomp) will not work. Appreciate any guidance. Regards, Walter
The failover transport only works with ActiveMQ's openwire based protocol. For stomp you need to handle all exceptions and reconnect when something goes wrong.