Home > other >  Netty sends a request, set websocketPath path
Netty sends a request, set websocketPath path

Time:03-11




Netty sends a request, set websocketPath path, the server this is websocket path is localhost: 8080/ws,
This is a server configuration, set the request path is/ws
Public class WebsocketChatServerInitializer extends
ChannelInitializer {//1

@ Override
Public void initChannel SocketChannel (ch) throws the Exception {//2
ChannelPipeline pipeline=ch. Pipeline ();

pipeline.addLast(new HttpServerCodec());
Pipeline. AddLast (new HttpObjectAggregator (64 * 1024));
Pipeline. AddLast (new ChunkedWriteHandler ());
Pipeline. AddLast (new HttpRequestHandler ("/ws "));
Pipeline. AddLast (new WebSocketServerProtocolHandler ("/ws "));
Pipeline. AddLast (new TextWebSocketFrameHandler ());

}
}
I'm on the client side how to set the request path to/ws?
This is a client setup code, don't know how to set the request path
Public class SimpleChatClientInitializer extends ChannelInitializer {
@ Override
Public void initChannel SocketChannel (ch) throws the Exception {
ChannelPipeline pipeline=ch. Pipeline ();

Pipeline. AddLast (" framer, "new DelimiterBasedFrameDecoder (8192, Delimiters. LineDelimiter ()));
Pipeline. AddLast (" decoder, "new StringDecoder ());
Pipeline. AddLast (" encoder ", new StringEncoder ());
Pipeline. AddLast (" handler ", new SimpleChatClientHandler ());

}
}

CodePudding user response:

I also am this problem, I didn't think so over the years is still the problem
  • Related