用netty简单作了个服务端用户接收客户端信息,但是无法接收客户端发送过来的信息,channelRead打断点一直进不去,服务端发送过去的客户端倒是能接收
代码如下public class MyChannelInitializer extends ChannelInitializer {
@Override
protected void initChannel(SocketChannel channel) {
channel.pipeline().addLast(new LineBasedFrameDecoder(1024));
channel.pipeline().addLast(new StringDecoder(Charset.forName("GBK")));
channel.pipeline().addLast(new StringEncoder(Charset.forName("GBK")));
channel.pipeline().addLast(new MyServerHandler());
}
}public class MyServerHandler extends ChannelInboundHandlerAdapter {
@Override
public void channelActive(ChannelHandlerContext ctx) throws Exception {
String str = "通知客户端链接建立成功" + " " + new Date() + " " + channel.localAddress().getHostString() + "\r\n";
<