Commit 50a8f74e73ead1a1217d718490904fa1ae736565

Authored by lijianfa_14810364212
1 parent 9fb13737

fix:解决TCP设备特殊字符密码不能连接的问题

... ... @@ -17,6 +17,8 @@ import io.netty.channel.ChannelHandlerContext;
17 17 import io.netty.channel.ChannelInboundHandlerAdapter;
18 18 import io.netty.util.ReferenceCountUtil;
19 19 import java.net.InetSocketAddress;
  20 +import java.nio.ByteBuffer;
  21 +import java.nio.charset.StandardCharsets;
20 22 import java.util.*;
21 23
22 24 import io.netty.util.concurrent.Future;
... ... @@ -79,7 +81,7 @@ public class TcpTransportHandler extends ChannelInboundHandlerAdapter implements
79 81 if (msg instanceof ByteBuf) {
80 82 ByteBuf message = (ByteBuf) msg;
81 83 byte[] byteMsg = ByteBufUtils.buf2Bytes(message);
82   - String msgStr = ByteUtils.bytesToStr(byteMsg);
  84 + String msgStr = StandardCharsets.UTF_8.decode(ByteBuffer.wrap(byteMsg)).toString();
83 85 log.debug(
84 86 "TCP服务【{}】收到设备【{}】来自【{}】数据【{}】",
85 87 sessionId,
... ...