io.netty.buffer.PooledUnsafeDirectByteBuf cannot be cast to java.lang.String
在netty信息发送的时候,ChannelInboundHandlerAdapter类下的channelRead方法中的参数msg转化string错误

这个不能直接转成String,而是
ByteBuf buf= (ByteBuf) msg;
String message = buf.toString(CharsetUtil.UTF_8);
这样进行转换才可以
同理,如果是类似的错误,你可以看看你的msg是否转换错误,即可排查
所有评论(0)