12:07:00[DEBUG][nioEventLoopGroup-2-1]c.i.n.HelloWorldClient- connetted...12:07:00[DEBUG][nioEventLoopGroup-2-1]i.n.h.l.LoggingHandler-[id:0x3c2ef3c2]REGISTERED12:07:00[DEBUG][nioEventLoopGroup-2-1]i.n.h.l.LoggingHandler-[id:0x3c2ef3c2]CONNECT:/192.168.0.103:909012:07:00[DEBUG][nioEventLoopGroup-2-1]i.n.h.l.LoggingHandler-[id:0x3c2ef3c2,L:/192.168.0.103:53155-R:/192.168.0.103:9090]ACTIVE12:07:00[DEBUG][nioEventLoopGroup-2-1]c.i.n.HelloWorldClient- sending...12:07:00[DEBUG][nioEventLoopGroup-2-1]i.n.h.l.LoggingHandler-[id:0x3c2ef3c2,L:/192.168.0.103:53155-R:/192.168.0.103:9090]WRITE:80B
+-------------------------------------------------+|0123456789 a b c d e f |+--------+-------------------------------------------------+----------------+|00000000|61616161000000006200000000000000|aaaa....b.......|
|00000010|63630000000000006400000000000000|cc......d.......|
|00000020|00000000000000006666666600000000|........ffff....|
|00000030|67676700000000006800000000000000|ggg.....h.......|
|00000040|69696969690000006a 6a 6a 6a 00000000|iiiii...jjjj....|
+--------+-------------------------------------------------+----------------+12:07:00[DEBUG][nioEventLoopGroup-2-1]i.n.h.l.LoggingHandler-[id:0x3c2ef3c2,L:/192.168.0.103:53155-R:/192.168.0.103:9090]FLUSH
服务端输出
12:06:51[DEBUG][main]c.i.n.HelloWorldServer-[id:0xe3d9713f] binding...12:06:51[DEBUG][main]c.i.n.HelloWorldServer-[id:0xe3d9713f,L:/192.168.0.103:9090] bound...12:07:00[DEBUG][nioEventLoopGroup-3-1]i.n.h.l.LoggingHandler-[id:0xd739f137,L:/192.168.0.103:9090-R:/192.168.0.103:53155]REGISTERED12:07:00[DEBUG][nioEventLoopGroup-3-1]i.n.h.l.LoggingHandler-[id:0xd739f137,L:/192.168.0.103:9090-R:/192.168.0.103:53155]ACTIVE12:07:00[DEBUG][nioEventLoopGroup-3-1]c.i.n.HelloWorldServer- connected [id:0xd739f137,L:/192.168.0.103:9090-R:/192.168.0.103:53155]12:07:00[DEBUG][nioEventLoopGroup-3-1]i.n.h.l.LoggingHandler-[id:0xd739f137,L:/192.168.0.103:9090-R:/192.168.0.103:53155]READ:8B
+-------------------------------------------------+|0123456789 a b c d e f |+--------+-------------------------------------------------+----------------+|00000000|6161616100000000|aaaa....|+--------+-------------------------------------------------+----------------+12:07:00[DEBUG][nioEventLoopGroup-3-1]i.n.h.l.LoggingHandler-[id:0xd739f137,L:/192.168.0.103:9090-R:/192.168.0.103:53155]READ:8B
+-------------------------------------------------+|0123456789 a b c d e f |+--------+-------------------------------------------------+----------------+|00000000|6200000000000000|b.......|+--------+-------------------------------------------------+----------------+12:07:00[DEBUG][nioEventLoopGroup-3-1]i.n.h.l.LoggingHandler-[id:0xd739f137,L:/192.168.0.103:9090-R:/192.168.0.103:53155]READ:8B
+-------------------------------------------------+|0123456789 a b c d e f |+--------+-------------------------------------------------+----------------+|00000000|6363000000000000|cc......|+--------+-------------------------------------------------+----------------+12:07:00[DEBUG][nioEventLoopGroup-3-1]i.n.h.l.LoggingHandler-[id:0xd739f137,L:/192.168.0.103:9090-R:/192.168.0.103:53155]READ:8B
+-------------------------------------------------+|0123456789 a b c d e f |+--------+-------------------------------------------------+----------------+|00000000|6400000000000000|d.......|+--------+-------------------------------------------------+----------------+12:07:00[DEBUG][nioEventLoopGroup-3-1]i.n.h.l.LoggingHandler-[id:0xd739f137,L:/192.168.0.103:9090-R:/192.168.0.103:53155]READ:8B
+-------------------------------------------------+|0123456789 a b c d e f |+--------+-------------------------------------------------+----------------+|00000000|0000000000000000|........|+--------+-------------------------------------------------+----------------+12:07:00[DEBUG][nioEventLoopGroup-3-1]i.n.h.l.LoggingHandler-[id:0xd739f137,L:/192.168.0.103:9090-R:/192.168.0.103:53155]READ:8B
+-------------------------------------------------+|0123456789 a b c d e f |+--------+-------------------------------------------------+----------------+|00000000|6666666600000000|ffff....|+--------+-------------------------------------------------+----------------+12:07:00[DEBUG][nioEventLoopGroup-3-1]i.n.h.l.LoggingHandler-[id:0xd739f137,L:/192.168.0.103:9090-R:/192.168.0.103:53155]READ:8B
+-------------------------------------------------+|0123456789 a b c d e f |+--------+-------------------------------------------------+----------------+|00000000|6767670000000000|ggg.....|+--------+-------------------------------------------------+----------------+12:07:00[DEBUG][nioEventLoopGroup-3-1]i.n.h.l.LoggingHandler-[id:0xd739f137,L:/192.168.0.103:9090-R:/192.168.0.103:53155]READ:8B
+-------------------------------------------------+|0123456789 a b c d e f |+--------+-------------------------------------------------+----------------+|00000000|6800000000000000|h.......|+--------+-------------------------------------------------+----------------+12:07:00[DEBUG][nioEventLoopGroup-3-1]i.n.h.l.LoggingHandler-[id:0xd739f137,L:/192.168.0.103:9090-R:/192.168.0.103:53155]READ:8B
+-------------------------------------------------+|0123456789 a b c d e f |+--------+-------------------------------------------------+----------------+|00000000|6969696969000000|iiiii...|+--------+-------------------------------------------------+----------------+12:07:00[DEBUG][nioEventLoopGroup-3-1]i.n.h.l.LoggingHandler-[id:0xd739f137,L:/192.168.0.103:9090-R:/192.168.0.103:53155]READ:8B
+-------------------------------------------------+|0123456789 a b c d e f |+--------+-------------------------------------------------+----------------+|00000000|6a 6a 6a 6a 00000000|jjjj....|+--------+-------------------------------------------------+----------------+12:07:00[DEBUG][nioEventLoopGroup-3-1]i.n.h.l.LoggingHandler-[id:0xd739f137,L:/192.168.0.103:9090-R:/192.168.0.103:53155]READCOMPLETE
publicclassHelloWorldClient{staticfinalLogger log =LoggerFactory.getLogger(HelloWorldClient.class);publicstaticvoidmain(String[] args){NioEventLoopGroup worker =newNioEventLoopGroup();try{Bootstrap bootstrap =newBootstrap();
bootstrap.channel(NioSocketChannel.class);
bootstrap.group(worker);
bootstrap.handler(newChannelInitializer<SocketChannel>(){@OverrideprotectedvoidinitChannel(SocketChannel ch)throwsException{
log.debug("connetted...");
ch.pipeline().addLast(newLoggingHandler(LogLevel.DEBUG));
ch.pipeline().addLast(newChannelInboundHandlerAdapter(){@OverridepublicvoidchannelActive(ChannelHandlerContext ctx)throwsException{
log.debug("sending...");Random r =newRandom();char c ='a';ByteBuf buffer = ctx.alloc().buffer();for(int i =0; i <10; i++){// 写 `随机个数` 个c(个数最少为1,最大为16)for(int j =1; j <= r.nextInt(16)+1; j++){
buffer.writeByte((byte) c);}// ASCLL码 中 10 代表换行符
buffer.writeByte(10);
c++;// 让c加一,也就是 a -> b -> c -> d ...}// 发送的长度不固定,但每次发送的最后一个字节都是换行符
ctx.writeAndFlush(buffer);}});}});ChannelFuture channelFuture = bootstrap.connect("192.168.0.103",9090).sync();
channelFuture.channel().closeFuture().sync();}catch(InterruptedException e){
log.error("client error", e);}finally{
worker.shutdownGracefully();}}}
客户端输出
14:08:18[DEBUG][nioEventLoopGroup-2-1]c.i.n.HelloWorldClient- connetted...14:08:18[DEBUG][nioEventLoopGroup-2-1]i.n.h.l.LoggingHandler-[id:0x1282d755]REGISTERED14:08:18[DEBUG][nioEventLoopGroup-2-1]i.n.h.l.LoggingHandler-[id:0x1282d755]CONNECT:/192.168.0.103:909014:08:18[DEBUG][nioEventLoopGroup-2-1]i.n.h.l.LoggingHandler-[id:0x1282d755,L:/192.168.0.103:63641-R:/192.168.0.103:9090]ACTIVE14:08:18[DEBUG][nioEventLoopGroup-2-1]c.i.n.HelloWorldClient- sending...14:08:18[DEBUG][nioEventLoopGroup-2-1]i.n.h.l.LoggingHandler-[id:0x1282d755,L:/192.168.0.103:63641-R:/192.168.0.103:9090]WRITE:60B
+-------------------------------------------------+|0123456789 a b c d e f |+--------+-------------------------------------------------+----------------+|00000000|610a 6262620a 6363630a 64640a 656565|a.bbb.ccc.dd.eee||00000010|656565656565650a 66660a 6767676767|eeeeeee.ff.ggggg||00000020|67670a 686868680a 696969696969690a |gg.hhhh.iiiiiii.|
|00000030|6a 6a 6a 6a 6a 6a 6a 6a 6a 6a 6a 0a |jjjjjjjjjjj.|+--------+-------------------------------------------------+----------------+14:08:18[DEBUG][nioEventLoopGroup-2-1]i.n.h.l.LoggingHandler-[id:0x1282d755,L:/192.168.0.103:63641-R:/192.168.0.103:9090]FLUSH
服务端输出
14:08:18[DEBUG][nioEventLoopGroup-3-5]c.i.n.HelloWorldServer- connected [id:0xa4b3be43,L:/192.168.0.103:9090-R:/192.168.0.103:63641]14:08:18[DEBUG][nioEventLoopGroup-3-5]i.n.h.l.LoggingHandler-[id:0xa4b3be43,L:/192.168.0.103:9090-R:/192.168.0.103:63641]READ:1B
+-------------------------------------------------+|0123456789 a b c d e f |+--------+-------------------------------------------------+----------------+|00000000|61|a |+--------+-------------------------------------------------+----------------+14:08:18[DEBUG][nioEventLoopGroup-3-5]i.n.h.l.LoggingHandler-[id:0xa4b3be43,L:/192.168.0.103:9090-R:/192.168.0.103:63641]READ:3B
+-------------------------------------------------+|0123456789 a b c d e f |+--------+-------------------------------------------------+----------------+|00000000|626262|bbb |+--------+-------------------------------------------------+----------------+14:08:18[DEBUG][nioEventLoopGroup-3-5]i.n.h.l.LoggingHandler-[id:0xa4b3be43,L:/192.168.0.103:9090-R:/192.168.0.103:63641]READ:3B
+-------------------------------------------------+|0123456789 a b c d e f |+--------+-------------------------------------------------+----------------+|00000000|636363|ccc |+--------+-------------------------------------------------+----------------+14:08:18[DEBUG][nioEventLoopGroup-3-5]i.n.h.l.LoggingHandler-[id:0xa4b3be43,L:/192.168.0.103:9090-R:/192.168.0.103:63641]READ:2B
+-------------------------------------------------+|0123456789 a b c d e f |+--------+-------------------------------------------------+----------------+|00000000|6464|dd |+--------+-------------------------------------------------+----------------+14:08:18[DEBUG][nioEventLoopGroup-3-5]i.n.h.l.LoggingHandler-[id:0xa4b3be43,L:/192.168.0.103:9090-R:/192.168.0.103:63641]READ:10B
+-------------------------------------------------+|0123456789 a b c d e f |+--------+-------------------------------------------------+----------------+|00000000|65656565656565656565|eeeeeeeeee |+--------+-------------------------------------------------+----------------+14:08:18[DEBUG][nioEventLoopGroup-3-5]i.n.h.l.LoggingHandler-[id:0xa4b3be43,L:/192.168.0.103:9090-R:/192.168.0.103:63641]READ:2B
+-------------------------------------------------+|0123456789 a b c d e f |+--------+-------------------------------------------------+----------------+|00000000|6666|ff |+--------+-------------------------------------------------+----------------+14:08:18[DEBUG][nioEventLoopGroup-3-5]i.n.h.l.LoggingHandler-[id:0xa4b3be43,L:/192.168.0.103:9090-R:/192.168.0.103:63641]READ:7B
+-------------------------------------------------+|0123456789 a b c d e f |+--------+-------------------------------------------------+----------------+|00000000|67676767676767|ggggggg |+--------+-------------------------------------------------+----------------+14:08:18[DEBUG][nioEventLoopGroup-3-5]i.n.h.l.LoggingHandler-[id:0xa4b3be43,L:/192.168.0.103:9090-R:/192.168.0.103:63641]READ:4B
+-------------------------------------------------+|0123456789 a b c d e f |+--------+-------------------------------------------------+----------------+|00000000|68686868|hhhh |+--------+-------------------------------------------------+----------------+14:08:18[DEBUG][nioEventLoopGroup-3-5]i.n.h.l.LoggingHandler-[id:0xa4b3be43,L:/192.168.0.103:9090-R:/192.168.0.103:63641]READ:7B
+-------------------------------------------------+|0123456789 a b c d e f |+--------+-------------------------------------------------+----------------+|00000000|69696969696969|iiiiiii |+--------+-------------------------------------------------+----------------+14:08:18[DEBUG][nioEventLoopGroup-3-5]i.n.h.l.LoggingHandler-[id:0xa4b3be43,L:/192.168.0.103:9090-R:/192.168.0.103:63641]READ:11B
+-------------------------------------------------+|0123456789 a b c d e f |+--------+-------------------------------------------------+----------------+|00000000|6a 6a 6a 6a 6a 6a 6a 6a 6a 6a 6a |jjjjjjjjjjj |+--------+-------------------------------------------------+----------------+14:08:18[DEBUG][nioEventLoopGroup-3-5]i.n.h.l.LoggingHandler-[id:0xa4b3be43,L:/192.168.0.103:9090-R:/192.168.0.103:63641]READCOMPLETE
可以使用LengthFieldBasedFrameDecoder(int maxFrameLength, int lengthFieldOffset, int lengthFieldLength, int lengthAdjustment, int initialBytesToStrip),第一个参数maxFrameLength表示窗口大小,剩余的参数含义如下:
lengthFieldOffset = 1 (= the length of HDR1):长度字段偏转,即第一个字节后面是内容的长度 lengthFieldLength = 2 (长度部分占2个字节) lengthAdjustment = 1 (= the length of HDR2):内容字段偏转,长度部分后再隔一个字节是内容部分 initialBytesToStrip = 3 (= the length of HDR1 + LEN):剥离前面3个字节不要了
下面的示例中,HDR1占一个字节,LENGTH占两个字节,HDR2占一个字节, Actual Content内容部分占12个字节(HELLO, WORLD中间有个空格)
20:23:18[DEBUG][main]i.n.handler.logging.LoggingHandler-[id:0xembedded,L:embedded -R:embedded]REGISTERED20:23:18[DEBUG][main]i.n.handler.logging.LoggingHandler-[id:0xembedded,L:embedded -R:embedded]ACTIVE20:23:18[DEBUG][main]i.n.handler.logging.LoggingHandler-[id:0xembedded,L:embedded -R:embedded]READ:13B
+-------------------------------------------------+|0123456789 a b c d e f |+--------+-------------------------------------------------+----------------+|00000000|0268656c 6c 6f2c 20776f726c 64|.hello, world |+--------+-------------------------------------------------+----------------+20:23:18[DEBUG][main]i.n.handler.logging.LoggingHandler-[id:0xembedded,L:embedded -R:embedded]READ:4B
+-------------------------------------------------+|0123456789 a b c d e f |+--------+-------------------------------------------------+----------------+|00000000|02486921|.Hi!|+--------+-------------------------------------------------+----------------+20:23:18[DEBUG][main]i.n.handler.logging.LoggingHandler-[id:0xembedded,L:embedded -R:embedded]READCOMPLETE
在发送消息前,先约定用定长字节表示接下来数据的长度
// LengthFieldBasedFrameDecoder(int maxFrameLength, int lengthFieldOffset, int lengthFieldLength, int lengthAdjustment, int initialBytesToStrip)// 最大长度,长度偏移,长度占用字节,长度调整,剥离字节数
ch.pipeline().addLast(newLengthFieldBasedFrameDecoder(1024,0,1,0,1));
14:37:10[DEBUG][nioEventLoopGroup-2-1]c.i.n.HelloWorldClient- connetted...14:37:10[DEBUG][nioEventLoopGroup-2-1]i.n.h.l.LoggingHandler-[id:0xf0f347b8]REGISTERED14:37:10[DEBUG][nioEventLoopGroup-2-1]i.n.h.l.LoggingHandler-[id:0xf0f347b8]CONNECT:/192.168.0.103:909014:37:10[DEBUG][nioEventLoopGroup-2-1]i.n.h.l.LoggingHandler-[id:0xf0f347b8,L:/192.168.0.103:49979-R:/192.168.0.103:9090]ACTIVE14:37:10[DEBUG][nioEventLoopGroup-2-1]c.i.n.HelloWorldClient- sending...14:37:10[DEBUG][nioEventLoopGroup-2-1]i.n.h.l.LoggingHandler-[id:0xf0f347b8,L:/192.168.0.103:49979-R:/192.168.0.103:9090]WRITE:97B
+-------------------------------------------------+|0123456789 a b c d e f |+--------+-------------------------------------------------+----------------+|00000000|09616161616161616161096262626262|.aaaaaaaaa.bbbbb||00000010|62626262066363636363630864646464|bbbb.cccccc.dddd||00000020|646464640f6565656565656565656565|dddd.eeeeeeeeeee||00000030|656565650d6666666666666666666666|eeee.fffffffffff||00000040|66660267670268680e 69696969696969|ff.gg.hh.iiiiiii||00000050|69696969696969096a 6a 6a 6a 6a 6a 6a 6a |iiiiiii.jjjjjjjj||00000060|6a |j |+--------+-------------------------------------------------+----------------+14:37:10[DEBUG][nioEventLoopGroup-2-1]i.n.h.l.LoggingHandler-[id:0xf0f347b8,L:/192.168.0.103:49979-R:/192.168.0.103:9090]FLUSH
服务端输出
14:36:50[DEBUG][main]c.i.n.HelloWorldServer-[id:0xdff439d3] binding...14:36:51[DEBUG][main]c.i.n.HelloWorldServer-[id:0xdff439d3,L:/192.168.0.103:9090] bound...14:37:10[DEBUG][nioEventLoopGroup-3-1]i.n.h.l.LoggingHandler-[id:0x744f2b47,L:/192.168.0.103:9090-R:/192.168.0.103:49979]REGISTERED14:37:10[DEBUG][nioEventLoopGroup-3-1]i.n.h.l.LoggingHandler-[id:0x744f2b47,L:/192.168.0.103:9090-R:/192.168.0.103:49979]ACTIVE14:37:10[DEBUG][nioEventLoopGroup-3-1]c.i.n.HelloWorldServer- connected [id:0x744f2b47,L:/192.168.0.103:9090-R:/192.168.0.103:49979]14:37:10[DEBUG][nioEventLoopGroup-3-1]i.n.h.l.LoggingHandler-[id:0x744f2b47,L:/192.168.0.103:9090-R:/192.168.0.103:49979]READ:9B
+-------------------------------------------------+|0123456789 a b c d e f |+--------+-------------------------------------------------+----------------+|00000000|616161616161616161|aaaaaaaaa |+--------+-------------------------------------------------+----------------+14:37:10[DEBUG][nioEventLoopGroup-3-1]i.n.h.l.LoggingHandler-[id:0x744f2b47,L:/192.168.0.103:9090-R:/192.168.0.103:49979]READ:9B
+-------------------------------------------------+|0123456789 a b c d e f |+--------+-------------------------------------------------+----------------+|00000000|626262626262626262|bbbbbbbbb |+--------+-------------------------------------------------+----------------+14:37:10[DEBUG][nioEventLoopGroup-3-1]i.n.h.l.LoggingHandler-[id:0x744f2b47,L:/192.168.0.103:9090-R:/192.168.0.103:49979]READ:6B
+-------------------------------------------------+|0123456789 a b c d e f |+--------+-------------------------------------------------+----------------+|00000000|636363636363|cccccc |+--------+-------------------------------------------------+----------------+14:37:10[DEBUG][nioEventLoopGroup-3-1]i.n.h.l.LoggingHandler-[id:0x744f2b47,L:/192.168.0.103:9090-R:/192.168.0.103:49979]READ:8B
+-------------------------------------------------+|0123456789 a b c d e f |+--------+-------------------------------------------------+----------------+|00000000|6464646464646464|dddddddd |+--------+-------------------------------------------------+----------------+14:37:10[DEBUG][nioEventLoopGroup-3-1]i.n.h.l.LoggingHandler-[id:0x744f2b47,L:/192.168.0.103:9090-R:/192.168.0.103:49979]READ:15B
+-------------------------------------------------+|0123456789 a b c d e f |+--------+-------------------------------------------------+----------------+|00000000|656565656565656565656565656565|eeeeeeeeeeeeeee |+--------+-------------------------------------------------+----------------+14:37:10[DEBUG][nioEventLoopGroup-3-1]i.n.h.l.LoggingHandler-[id:0x744f2b47,L:/192.168.0.103:9090-R:/192.168.0.103:49979]READ:13B
+-------------------------------------------------+|0123456789 a b c d e f |+--------+-------------------------------------------------+----------------+|00000000|66666666666666666666666666|fffffffffffff |+--------+-------------------------------------------------+----------------+14:37:10[DEBUG][nioEventLoopGroup-3-1]i.n.h.l.LoggingHandler-[id:0x744f2b47,L:/192.168.0.103:9090-R:/192.168.0.103:49979]READ:2B
+-------------------------------------------------+|0123456789 a b c d e f |+--------+-------------------------------------------------+----------------+|00000000|6767|gg |+--------+-------------------------------------------------+----------------+14:37:10[DEBUG][nioEventLoopGroup-3-1]i.n.h.l.LoggingHandler-[id:0x744f2b47,L:/192.168.0.103:9090-R:/192.168.0.103:49979]READ:2B
+-------------------------------------------------+|0123456789 a b c d e f |+--------+-------------------------------------------------+----------------+|00000000|6868|hh |+--------+-------------------------------------------------+----------------+14:37:10[DEBUG][nioEventLoopGroup-3-1]i.n.h.l.LoggingHandler-[id:0x744f2b47,L:/192.168.0.103:9090-R:/192.168.0.103:49979]READ:14B
+-------------------------------------------------+|0123456789 a b c d e f |+--------+-------------------------------------------------+----------------+|00000000|6969696969696969696969696969|iiiiiiiiiiiiii |+--------+-------------------------------------------------+----------------+14:37:10[DEBUG][nioEventLoopGroup-3-1]i.n.h.l.LoggingHandler-[id:0x744f2b47,L:/192.168.0.103:9090-R:/192.168.0.103:49979]READ:9B
+-------------------------------------------------+|0123456789 a b c d e f |+--------+-------------------------------------------------+----------------+|00000000|6a 6a 6a 6a 6a 6a 6a 6a 6a |jjjjjjjjj |+--------+-------------------------------------------------+----------------+14:37:10[DEBUG][nioEventLoopGroup-3-1]i.n.h.l.LoggingHandler-[id:0x744f2b47,L:/192.168.0.103:9090-R:/192.168.0.103:49979]READCOMPLETE
21:00:38[DEBUG][nioEventLoopGroup-2-1]i.n.handler.logging.LoggingHandler-[id:0x18a7da78]REGISTERED21:00:38[DEBUG][nioEventLoopGroup-2-1]i.n.handler.logging.LoggingHandler-[id:0x18a7da78]CONNECT: localhost/127.0.0.1:637921:00:38[DEBUG][nioEventLoopGroup-2-1]i.n.handler.logging.LoggingHandler-[id:0x18a7da78,L:/127.0.0.1:54530-R:localhost/127.0.0.1:6379]ACTIVE21:00:38[DEBUG][nioEventLoopGroup-2-1]i.n.handler.logging.LoggingHandler-[id:0x18a7da78,L:/127.0.0.1:54530-R:localhost/127.0.0.1:6379]WRITE:37B
+-------------------------------------------------+|0123456789 a b c d e f |+--------+-------------------------------------------------+----------------+|00000000|2a 330d0a 24330d0a 7365740d0a 24340d|*3..$3..set..$4.||00000010|0a 6e 616d650d0a 24380d0a 7a 68616e 67|.name..$8..zhang||00000020|73616e 0d0a |san..|+--------+-------------------------------------------------+----------------+21:00:38[DEBUG][nioEventLoopGroup-2-1]i.n.handler.logging.LoggingHandler-[id:0x18a7da78,L:/127.0.0.1:54530-R:localhost/127.0.0.1:6379]FLUSH21:00:38[DEBUG][nioEventLoopGroup-2-1]i.n.handler.logging.LoggingHandler-[id:0x18a7da78,L:/127.0.0.1:54530-R:localhost/127.0.0.1:6379]READ:5B
+-------------------------------------------------+|0123456789 a b c d e f |+--------+-------------------------------------------------+----------------+|00000000|2b 4f4b 0d0a |+OK..|+--------+-------------------------------------------------+----------------+21:00:38[DEBUG][nioEventLoopGroup-2-1]i.n.handler.logging.LoggingHandler-[id:0x18a7da78,L:/127.0.0.1:54530-R:localhost/127.0.0.1:6379]READCOMPLETE