Closed BitKnitting closed 5 years ago
Looking at the Adafruit MQTT API it looks like a fairly standard broker so you should be fine with it, what difficulty are you having?
Thank you for the reply.
I seem to be able to connect ok using client = mqtt.MqttClient(broker, ioKey);
where ioKey is my Adafruit io key. I have an Adafruit io feed (topic) sketchy/feeds/test (sketchy is my user account name).
Running the flutter example in a simulator (with ioKey), I am able to connect:
flutter: 2019-02-06 12:49:02.722472 -- SynchronousMqttConnectionHandler::internalConnect
exited with state Connection status is connected with return code connectionAccepted
flutter: MQTT client connected
Moving on to messages, I use your UI and tap the FAB to add a message.
for topic I use sketchy/feeds/test
with a message of hello
This message is not received by Adafruit.io. Here are the logfile entries:
flutter: 2019-02-06 13:05:06.743372 -- MqttConnectionHandler::sendMessage - MQTTMessage of type MqttMessageType.publish
Header: MessageType = MqttMessageType.publish, Duplicate = false, Retain = false, Qos = MqttQos.atMostOnce, Size = 0
Publish Variable Header: TopicName={sketchy/feeds/test}, MessageIdentifier={3}, VH Length={0}
Payload: {5 bytes={<104><101><108><108><111>
flutter: 2019-02-06 13:05:06.822678 -- MqttConnection::_onDone - calling disconnected callback
flutter: MQTT client disconnected
You may find this example is out of date, I don't use flutter so i don't maintain it as such. There is a test example in the examples directory that just runs in the VM called mqtt_client, just edit this to set your Adafruit credentials and see what happens. If the fault still persists its with the Adafruit broker.
Thank you. While i get back the mqtt client is connected, the log shows: flutter: 2019-02-11 10:39:41.890377 -- MqttConnectPayload::Client id exceeds spec value of 23
Looking in MqttConnectPayload:
MqttLogger.log(
'MqttConnectPayload::Client id exceeds spec value of ${Constants.maxClientIdentifierLengthSpec}');
}
_clientIdentifier = id;
the client id that Adafruit.io uses is 40 bytes. This exceeds the 23. Is the log for info or will it prohibit anything?
This is just a warning in that the MQTT 3.1 spec states that the Client Identifier must be 23 characters in length. In practice this isn't always respected by most commercial brokers, also in V3.1.1 this is relaxed to 65535. I should really check the version you have set before printing this and only print it for v3.1, it can be safely ignored.
Thank you. From what i can tell, my connection log and mqtt traffic is identical to the successful connection posted in https://github.com/shamblett/mqtt_client/issues/2. However, publish returns immediately
flutter: 2019-02-12 04:33:46.635595 -- MqttConnectionHandler::sendMessage - MQTTMessage of type MqttMessageType.publish
Header: MessageType = MqttMessageType.publish, Duplicate = false, Retain = false, Qos = MqttQos.exactlyOnce, Size = 0
Publish Variable Header: TopicName={sketchy/feeds/test}, MessageIdentifier={1}, VH Length={0}
Payload: {8 bytes={<24><0><0><0><0><0><0><0>
flutter: 2019-02-12 04:33:46.716966 -- MqttConnection::_onDone - calling disconnected callback
flutter: MQTT client disconnected
i do not see this traffic:
2017-11-02 21:07:20.390766 -- MqttConnection::_onData
2017-11-02 21:07:20.391839 -- MqttConnection::_onData - message received MQTTMessage of type MqttMessageType.publishReceived
Header: MessageType = MqttMessageType.publishReceived, Duplicate = false, Retain = false, Qos = MqttQos.atMostOnce, Size = 2
PublishReceived Variable Header: MessageIdentifier={1}
2017-11-02 21:07:20.391933 -- MqttConnection::_onData - message processed
2017-11-02 21:07:20.392845 -- MqttConnectionHandler::sendMessage - MQTTMessage of type MqttMessageType.publishRelease
Header: MessageType = MqttMessageType.publishRelease, Duplicate = false, Retain = false, Qos = MqttQos.atMostOnce, Size = 0
PublishRelease Variable Header: MessageIdentifier={1}
rather, i get an immediate _onDone w/o a message received from the broker. Do you know why the client would immediately go to _onDone when i publish?
OnDone is usually an indication of broker disconnection, i.e the broker has received the publish message, taken offence to something and disconnected. You could try swapping the protocol version between 3.1 and 3.1.1 and see what happens, your also using MqttQos.exactlyOnce, try changing the QoS also. Your only other recourse its to get the broker logs and see why its disconnecting.
I was able to get this to work with Adafruit.io. It turned out I needed to add 1.authenticateAs()to the
MqttConnectMessage'. Thank you VERY much for your help and insights.
I am having difficulty connecting to an Adafruit.io feed. Should connecting to Adafruit.io be straightforward? here is a brief doc on adafruit.io: https://io.adafruit.com/api/docs/#