Я сталкиваюсь с ошибкой при подписке на брокер MQTT (org.eclipse.paho.client.mqttv3.MqttClient) с именем пользователя и паролем:
Версия:
Paho MQTT Client: org.eclipse.paho.client.mqttv3-1.2.0.jar
Mosquitto Version: mosquitto-1.5
mosquitto-auth-plugin: compatible with 1.5
Error @ Брокер
1558438891: New connection from 192.168.50.128 on port 1883.
1558438891: |-- mosquitto_auth_unpwd_check(testUser)
1558438891: |-- ** checking backend sqlite
1558438891: |-- getuser(testUser) AUTHENTICATED=1 by sqlite
1558438891: New client connected from 192.168.50.128 as TestApp (c1, k60, u'testUser').
1558438891: No will message specified.
1558438891: Sending CONNACK to TestApp (0, 0)
1558438891: Received SUBSCRIBE from TestApp
1558438891: MyTopic/# (QoS 1)
1558438891: Sending SUBACK to TestApp
1558438891: Socket error on client TestApp, disconnecting.
1558438891: |-- mosquitto_auth_acl_check(..., client id not available, testUser, MyTopic/#, MOSQ_ACL_WRITE)
1558438891: |-- aclcheck(testUser, MyTopic/#, 4) CACHEDAUTH: 17
Фрагмент кода:
options = new MqttConnectOptions();
//...
//...
options.setCleanSession(true);
options.setUserName(username);
options.setPassword(password.toCharArray());
//...
client = new MqttClient(clientHostname.toString(), "TestApp"); ===> OK
//...
client.subscribe(lS.getSubscriptionTopic(), 1); ===> Error
MqttException (128)
at org.eclipse.paho.client.mqttv3.MqttClient.subscribe(MqttClient.java:438)
at org.eclipse.paho.client.mqttv3.MqttClient.subscribe(MqttClient.java:424)