Commit 3043f4803c6c6152ba97cf625abe2a35d4d96f75
Merge branch 'fix/tcp-msg' into 'master_dev'
perf:解决TCP设备特殊字符密码不能连接的问题 See merge request yunteng/thingskit!446
Showing
1 changed file
with
3 additions
and
1 deletions
... | ... | @@ -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, | ... | ... |