Code Monkey home page Code Monkey logo

Comments (11)

shamblett avatar shamblett commented on August 30, 2024

OK, I think I've seen this before, your disconnecting from the broker, try it again with logging on,

client.logging(true);

from mqtt_client.

shamblett avatar shamblett commented on August 30, 2024

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.

from mqtt_client.

vinicentus avatar vinicentus commented on August 30, 2024

Thank you, I will try the new version soon...

from mqtt_client.

shamblett avatar shamblett commented on August 30, 2024

Republished version 1.9.1

from mqtt_client.

vinicentus avatar vinicentus commented on August 30, 2024

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.

from mqtt_client.

vinicentus avatar vinicentus commented on August 30, 2024
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.

from mqtt_client.

shamblett avatar shamblett commented on August 30, 2024

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.

from mqtt_client.

shamblett avatar shamblett commented on August 30, 2024

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.

from mqtt_client.

vinicentus avatar vinicentus commented on August 30, 2024

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.

from mqtt_client.

shamblett avatar shamblett commented on August 30, 2024

Ok, thanks

from mqtt_client.

cnqiuxue avatar cnqiuxue commented on August 30, 2024

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/

from mqtt_client.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.