红糖糍粑
我希望你得到一个解决方案。我不知道你的客户端,但是 paho-mqtt java 客户端可以自动重新连接。可以在“connectComplete(boolean reconnect, String s)”布尔参数中检查此重新连接public class MqttautoClient implements MqttCallbackExtended {... @Override public void connectComplete(boolean reconnect, String s) { Log.d(TAG, "Connection connectComplete"); } @Override public void connectionLost(Throwable throwable) { Log.d(TAG, "Connection lost"); } @Override public void messageArrived(String topic, MqttMessage mqttMessage) throws Exception { Log.d(TAG, "messageArrived"); } public void deliveryComplete(IMqttDeliveryToken iMqttDeliveryToken) { Log.d(TAG, "deliveryComplete "); }}