为了演示 Paho MQTT,我下载了一个 Java 示例。
public class Thermometer {
public static final String BROKER_URL = "tcp://test.mosquitto.org:1883";
public static final String TOPIC = "xyz.abc";
private MqttClient client;
public Thermometer() {
try {
MemoryPersistence per = new MemoryPersistence();
String clientId = UUID.randomUUID().toString();
client = new MqttClient(BROKER_URL, clientId, per);
} catch (MqttException e) {
e.printStackTrace();
System.exit(1);
}
}
client = new MqttClient(BROKER_URL, clientId, per);
当我运行它时出现问题,它位于
org.eclipse.paho.client.mqttv3.MqttClient.(MqttClient.java:170) 在 mqtt_pub.Thermometer.(Thermometer.java:26) 在 mqtt_pub.Thermometer.main(温度计.java:65)
我发现 @throws IllegalArgumentException 如果 QoS 的值不是 0、1 或 2,但在他们没有提到的 MemoryPersistence 类中。请帮忙,提前谢谢你。