环境信息
- EMQ X 版本:4.3.10
- 操作系统及版本:centos7
- 其他
问题描述
private void deviceInfo(MqttMessage mqttMessage) {
//添加设备信息
IotDevice device = JSON.parseObject(new String(mqttMessage.getPayload()), IotDevice.class);
上面这个消息体 json 转化的时候如果失败,就会导致下面的异常一直循环发送,最终导致服务器崩溃!这个异常无法捕捉,请教下谁有什么好的方案吗?
12:39:18.964 [MQTT Ping: mqtt_client_e7aa5b095d939e8d659283d26950b06c] ERROR o.e.p.c.m.i.ClientState - [logToJsr47,210] - mqtt_client_e7aa5b095d939e8d659283d26950b06c: Timed out as no write activity, keepAlive=20,000,000,000 lastOutboundActivity=619,200,644,802,100 lastInboundActivity=619,200,655,607,800 time=619,782,713,292,200 lastPing=619,200,644,814,800
12:39:18.969 [MQTT Ping: mqtt_client_e7aa5b095d939e8d659283d26950b06c] ERROR c.s.s.m.c.MqttMessageCallback - [connectionLost,34] - 连接断开,正在尝试重新连接 >>>>>>>
12:39:18.969 [MQTT Ping: mqtt_client_e7aa5b095d939e8d659283d26950b06c] INFO c.s.s.m.MqttOperateClient - [connect,69] - 【MQTT客户端正在初始化】MQTT client init ......host:tcp://localhost:1883,clientId:mqtt_client_e7aa5b095d939e8d659283d26950b06c
12:39:18.973 [MQTT Ping: mqtt_client_e7aa5b095d939e8d659283d26950b06c] INFO c.s.s.m.MqttOperateClient - [connect,87] - 【MQTT客户端连接失败】MQTT client connected fail ✘......
MqttException (0) - java.net.NoRouteToHostException: No route to host: connect
at org.eclipse.paho.client.mqttv3.internal.ExceptionHelper.createMqttException(ExceptionHelper.java:38)
at org.eclipse.paho.client.mqttv3.internal.ClientComms$ConnectBG.run(ClientComms.java:738)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.net.NoRouteToHostException: No route to host: connect
at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:81)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:476)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:218)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:200)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:162)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:394)
at java.net.Socket.connect(Socket.java:606)
at org.eclipse.paho.client.mqttv3.internal.TCPNetworkModule.start(TCPNetworkModule.java:74)
at org.eclipse.paho.client.mqttv3.internal.ClientComms$ConnectBG.run(ClientComms.java:724)
... 1 more
客户机未连接 (32104)
at org.eclipse.paho.client.mqttv3.internal.ExceptionHelper.createMqttException(ExceptionHelper.java:31)
at org.eclipse.paho.client.mqttv3.internal.ClientComms.sendNoWait(ClientComms.java:205)
at org.eclipse.paho.client.mqttv3.MqttAsyncClient.subscribeBase(MqttAsyncClient.java:1088)
at org.eclipse.paho.client.mqttv3.MqttAsyncClient.subscribe(MqttAsyncClient.java:1152)
at org.eclipse.paho.client.mqttv3.MqttClient.subscribe(MqttClient.java:459)
at org.eclipse.paho.client.mqttv3.MqttClient.subscribe(MqttClient.java:429)
at org.eclipse.paho.client.mqttv3.MqttClient.subscribe(MqttClient.java:422)
at com.shanlomed.system.mqtt.MqttOperateClient.subscribe(MqttOperateClient.java:165)
at com.shanlomed.system.mqtt.config.MqttConfig.getMqttOperateClient(MqttConfig.java:70)
at com.shanlomed.system.mqtt.callback.MqttMessageCallback.connectionLost(MqttMessageCallback.java:37)
at org.eclipse.paho.client.mqttv3.internal.CommsCallback.connectionLost(CommsCallback.java:304)
at org.eclipse.paho.client.mqttv3.internal.ClientComms.shutdownConnection(ClientComms.java:441)
at org.eclipse.paho.client.mqttv3.internal.ClientComms.handleRunException(ClientComms.java:838)
at org.eclipse.paho.client.mqttv3.internal.ClientComms.checkForActivity(ClientComms.java:820)
at org.eclipse.paho.client.mqttv3.internal.ClientComms.checkForActivity(ClientComms.java:804)
at org.eclipse.paho.client.mqttv3.TimerPingSender$PingTask.run(TimerPingSender.java:79)
at java.util.TimerThread.mainLoop(Timer.java:555)
at java.util.TimerThread.run(Timer.java:505)
客户机未连接 (32104)