Closed Hecatoncheir closed 6 years ago
Hi, I would actually not expect server...* to work. In MQTT, the topic level separator is /. Wildcards characters are + and #. For route server/log/web/test.a8fe5020-d2d0-11e7-d08b-6d9310df6f6b, I've tested subscribe server/+/+/+ and subscribe server/# and both work fine.
You can get more details there: https://www.hivemq.com/blog/mqtt-essentials-part-5-mqtt-topics-best-practices
kind regards,
Jean-Noel
Hi,thanks for your answer. I make test like: https://gist.github.com/Rasarts/01d94b122ee1a96f259aa8353f57afd4 And I get error. Maybe it didn't work with QOS_1?
Hi, I didn't manage to reproduce your error. I tried with QOS_1 and that worked. Could you please confirm the MQTT version of your broker? I've tested with Mosquitto, but you may be using a different broker. If so I would try to test using the same broker as yours. thanks.
I use RabbitMQ with Web MQTT Plugin.
With route like client1.subscribe('test queue', QOS_1,...)
and await client2.publish('test queue',..)
work fine.
Hi, As you are connecting through websocket you shouldn't use a MqttConnectionIOSocket to create your connection. Instead you should use a MqttConnectionIOWebSocket
There is a sample of using mqtt.dart over websocked under examples/mqtt_web.
Let me know if that fixes the issue.
Hi, It's not work, too.
https://gist.github.com/Rasarts/01d94b122ee1a96f259aa8353f57afd4 If I replace:
await client2.publish(
'server.log.web.test.a8fe5020-d2d0-11e7-d08b-6d9310df6f6b',
JSON.encode(sendedEntity));
to
await client2.publish(
'server.log.web.test',
JSON.encode(sendedEntity));
Then it's work, I can get message. But I need that uuid in path.
I'm getting the same error message when using a message payload that is a bit longer.
The topic is always the same: /binkyrailways/data
The payload is UTF8 encoded: Short payloads work. E.g.
{"type":"running"}
Longer payloads fail. E.g.
{"description":"Zwitserlandbaan (Dortmund)","locs":[{"description":"foo","owner":"Ewout"},{"description":"foo","owner":"Sjraar"},{"description":"foo","owner":"Sjraar"},{"description":"foo","owner":"Sjraar"},{"description":"foo","owner":"Sjraar"},{"description":"foo","owner":"Ewout"},{"description":"foo","owner":"Ewout"},{"description":"foo","owner":"Sjraar"},{"description":"foo","owner":"Ewout"},{"description":"foo","owner":"Sjraar"},{"description":"foo","owner":"Ewout"},{"description":"foo","owner":"Sjraar"},{"description":"foo","owner":"Ewout"},{"description":"foo","owner":"Sjraar"},{"description":"foo","owner":"Ewout"}],"type":"railway"}
Using mosquito broker. mqttcli
shows the topic as I expected it.
Additional info. I'm using it in flutter with socket IO.
I get error now: Connection Refused: bad user name or password It's worked before.
Connection Refused: bad user name or password
dart:async _Completer.completeError
package:mqtt/mqtt_client.dart 295:18 MqttClient._handleConnack
package:mqtt/mqtt_client.dart 226:30 MqttClient._processMqttMessage
package:mqtt/mqtt_client.dart 207:19 MqttClient._processData
package:mqtt/mqtt_connection_io_socket.dart 32:29 MqttConnectionIOSocket.startListening.<fn>
===== asynchronous gap ===========================
dart:io _Socket.listen
package:mqtt/mqtt_connection_io_socket.dart 31:13 MqttConnectionIOSocket.startListening
package:mqtt/mqtt_client.dart 169:21 MqttClient._handleConnected
package:mqtt/mqtt_client.dart 52:49 MqttClient.connect.<fn>
===== asynchronous gap ===========================
dart:async _Future.then
package:mqtt/mqtt_client.dart 52:31 MqttClient.connect
test/server/mqtt_test.dart 46:21 main.<fn>.<fn>
===== asynchronous gap ===========================
dart:async new Future.microtask
test/server/mqtt_test.dart 34:65 main.<fn>.<fn>
It could be the pull request I merged yesterday. Did you updated to the latest version?
Yes, in pubspec.lock I get:
mqtt:
description:
ref: master
resolved-ref: b115db58f1918906662d7ceb3fd092c94986d52c
url: "https://github.com/jnguillerme/mqtt.dart"
source: git
version: "1.0.1"
For experiment, to method _openSession I add:
m._userName = this._userName;
m._password =this._password;
Like:
void _openSession() {
print("Opening session");
MqttMessageConnect m = new MqttMessageConnect.setOptions(_clientID, _qos, _cleanSession);
m._userName = this._userName;
m._password =this._password;
if (_userName != null && _password != null) {
m.setUserNameAndPassword(_userName, _password);
}
// set will
m.setWill(_will);
_mqttConnection.sendMessageToBroker(m, debugMessage);
}
And it work now.
It should be fixed with package 1.1.3.
For subscribe to message with that route: server.log.web.test.a8fe5020-d2d0-11e7-d08b-6d9310df6f6b I try use :
subscribe("server.*.*.*.*")
orsubscribe("server.#")
and I get error: RangeError (end): Invalid value: Not in rangeBut for route server.log.web.test subscribe:
subscribe("server.*.*.*")
work fine.I miss something?