Closed vinicentus closed 6 years ago
OK, I think I've seen this before, your disconnecting from the broker, try it again with logging on,
client.logging(true);
Bit more on this, I've fixed the exception, it actually means the broker has not accepted the connection request for on of the following
if (ackMsg.variableHeader.returnCode == MqttConnectReturnCode.brokerUnavailable || ackMsg.variableHeader.returnCode == MqttConnectReturnCode.identifierRejected || ackMsg.variableHeader.returnCode == MqttConnectReturnCode.unacceptedProtocolVersion || ackMsg.variableHeader.returnCode == MqttConnectReturnCode.notAuthorized || ackMsg.variableHeader.returnCode == MqttConnectReturnCode.badUsernameOrPassword) {
or the incoming ack message cannot be decoded at all.
Thank you, I will try the new version soon...
Republished version 1.9.1
Maybe the names should be changed?
error: The name 'ConnectionState' is defined in the libraries 'async.dart' and 'mqtt_client.dart'. (ambiguous_import at [mqtt_test2] lib\main.dart:81)
error: The name 'ChangeNotifier' is defined in the libraries 'change_notifier.dart' and 'change_notifier.dart'. (ambiguous_import at [mqtt_test2] lib\main.dart:93)
error: The name 'ChangeNotifier' is defined in the libraries 'change_notifier.dart' and 'change_notifier.dart'. (ambiguous_import at [mqtt_test2] lib\main.dart:101)
One ChangeNotifier is in the flutter
package, and the other is in observable-0.22.1+3
, both of which are dart packages.
I/flutter (21503): EXAMPLE::Mosquitto client connecting....
I/flutter (21503): 2018-07-12 15:56:10.228887 -- SynchronousMqttConnectionHandler::disconnect
I/flutter (21503): 2018-07-12 15:56:10.245624 -- MqttConnectionHandler::sendMessage - MQTTMessage of type MqttMessageType.disconnect
I/flutter (21503): Header: MessageType = MqttMessageType.disconnect, Duplicate = false, Retain = false, Qos = MqttQos.atMostOnce, Size = 0
I/flutter (21503): 2018-07-12 15:56:10.246130 -- MqttConnectionHandler::sendMessage - not connected
I/flutter (21503): EXAMPLE::ERROR Mosquitto client connection failed - disconnecting, state is ConnectionState2.disconnected
Lost connection to device.
Error writing "build/flutter_assets/AssetManifest.json" to DevFS: HttpException: Connection closed before full header was received, uri = http://127.0.0.1:8106/
Error writing "build/flutter_assets/FontManifest.json" to DevFS: HttpException: Connection closed before full header was received, uri = http://127.0.0.1:8106/
Flutter doesn't really play nice with this. It looses connection to my test device. It could be my fault but idk.
Try prefixing your import of the mqtt_client,
import 'package:mqtt_client/mqtt_client.dart' as mqtt;
then anywhere where you use ant of it prefix it with 'mqtt.' this should stop name clashes. You can do this with any packages.
Yes, I never used flutter but this looks wrong, 'uri = http://127.0.0.1:8106/', mqtt_client just connects to its broker over a socket as shown in the example e.g test.mosquito.org on port 1883(default), there's no HTTP involved, also its logging as 127.0.0.1 which is localhost.
I'm sure there are other flutter users that are using the client, maybe ask on flutter list.
I'm not really sure what the problem is here, but I got it all working with this fork and the example (located in readme.md). https://github.com/benbehringer/mqtt_client
If you want to dig further I'd be happy to help although my experience with flutter and dart is pretty minimal. Otherwise you can close this issue.
Ok, thanks
Built build/app/outputs/apk/debug/app-debug.apk. Installing build/app/outputs/apk/app.apk... Syncing files to device YF XXXG... I/Process (19514): Sending signal. PID: 19514 SIG: 9 Lost connection to device. Error writing "build/flutter_assets/AssetManifest.json" to DevFS: HttpException: , uri = http://127.0.0.1:49865/ Error writing "build/flutter_assets/FontManifest.json" to DevFS: HttpException: , uri = http://127.0.0.1:49865/
So I get this error when trying to run the example as a flutter (0.5.1) app. Any ideas on what could be wrong?