1.问题
11月21日,云南勐腊发生地震,ICL在推送相关地震数据后,Netty客户端收到的数据在日志中显示为不完整的JSON数据,导致json反序列化失败:
pis.png
2.分析
PIS作为长链接的客户端,目前与ICL的通信协议是websocket,对应的数据处理报文类:io.netty.handler.codec.http.websocketx.TextWebSocketFrame
WebSocketFrame frame = (WebSocketFrame) msg;
if (frame instanceof TextWebSocketFrame) {
TextWebSocketFrame textFrame = (TextWebSocketFrame) frame;
String text = textFrame.text();
LOGGER.info("【PIS-client】 received message:{}", text);
TypeProtocol typeProtocol = JSON.parseObject(text, TypeProtocol.class);
MessageAction action = dispatcher.getMsgAction(typeProtocol.getType());
String response = action.process(text);
if (StringUtils.isNotBlank(response)) {
TextWebSocketFrame socketFrame = new