Comments (6)
OK, you are connecting to the broker and sending a connect message -
I/flutter (12154): 10-2023-01-19 14:18:21.639457 -- MqttConnectionHandlerBase::sendMessage - MQTTMessage of type MqttMessageType.connect
The broker is then disconnecting you
This is usually an indication of a protocol error. I can see this from your code above -
// Set the protocol to V3.1.1 for AWS IoT Core, if you fail to do this you will not receive a connect ack with the response code
// client.setProtocolV311();
You need to uncomment the line that sets the protocol to V3.1.1, see what happens then.
from mqtt_client.
OK, you are connecting to the broker and sending a connect message -
I/flutter (12154): 10-2023-01-19 14:18:21.639457 -- MqttConnectionHandlerBase::sendMessage - MQTTMessage of type MqttMessageType.connect
The broker is then disconnecting you
This is usually an indication of a protocol error. I can see this from your code above -
// Set the protocol to V3.1.1 for AWS IoT Core, if you fail to do this you will not receive a connect ack with the response code // client.setProtocolV311();
You need to uncomment the line that sets the protocol to V3.1.1, see what happens then.
I've uncommented that line and also tried with protocol to V3.1, all of them returned the same result,
logging uncommented protocol to V3.1.1:
I/flutter (13077): MQTT client connecting to AWS IoT using certificates....
I/flutter (13077): 1-2023-01-19 17:57:26.570182 -- MqttClient::connect - Connection timeout period is 5000 milliseconds
I/flutter (13077): 1-2023-01-19 17:57:26.579198 -- MqttClient::connect - keep alive is enabled with a value of 20 seconds
I/flutter (13077): 1-2023-01-19 17:57:26.581707 -- MqttConnectionKeepAlive:: Initialised with a keep alive value of 20 seconds
I/flutter (13077): 1-2023-01-19 17:57:26.582136 -- MqttConnectionKeepAlive:: Disconnect on no ping response is disabled
I/flutter (13077): 1-2023-01-19 17:57:26.585354 -- MqttConnectionHandlerBase::connect - server a3vd2md0ix5msi-ats.iot.us-east-1.amazonaws.com, port 8883
I/flutter (13077): 1-2023-01-19 17:57:26.587974 -- SynchronousMqttServerConnectionHandler::internalConnect entered
I/flutter (13077): 1-2023-01-19 17:57:26.588181 -- SynchronousMqttServerConnectionHandler::internalConnect - initiating connection try 0, auto reconnect in progress false
I/flutter (13077): 1-2023-01-19 17:57:26.588515 -- SynchronousMqttServerConnectionHandler::internalConnect - secure selected
I/flutter (13077): 1-2023-01-19 17:57:26.590829 -- SynchronousMqttServerConnectionHandler::internalConnect - calling connect
I/flutter (13077): 1-2023-01-19 17:57:26.591407 -- MqttSecureConnection::connect - entered
I/flutter (13077): 1-2023-01-19 17:57:27.127415 -- MqttSecureConnection::connect - securing socket
I/flutter (13077): 1-2023-01-19 17:57:27.130318 -- MqttSecureConnection::connect - start listening
I/flutter (13077): 1-2023-01-19 17:57:27.132408 -- MqttServerConnection::_startListening
I/flutter (13077): 1-2023-01-19 17:57:27.135641 -- SynchronousMqttServerConnectionHandler::internalConnect - connection complete
I/flutter (13077): 1-2023-01-19 17:57:27.135834 -- SynchronousMqttServerConnectionHandler::internalConnect sending connect message
I/flutter (13077): 1-2023-01-19 17:57:27.136179 -- MqttConnectionHandlerBase::sendMessage - MQTTMessage of type MqttMessageType.connect
I/flutter (13077): Header: MessageType = MqttMessageType.connect, Duplicate = false, Retain = false, Qos = MqttQos.atMostOnce, Size = 0
I/flutter (13077): Connect Variable Header: ProtocolName=MQTT, ProtocolVersion=4, ConnectFlags=Connect Flags: Reserved1=false, CleanStart=false, WillFlag=false, WillQos=MqttQos.atMostOnce, WillRetain=true, PasswordFlag=false, UserNameFlag=false, KeepAlive=20
I/flutter (13077): MqttConnectPayload - client identifier is : FlutterThing
I/flutter (13077): 1-2023-01-19 17:57:27.148816 -- SynchronousMqttServerConnectionHandler::internalConnect - pre sleep, state = Connection status is connecting with return code of noneSpecified and a disconnection origin of none
I/flutter (13077): 1-2023-01-19 17:57:29.350259 -- MqttConnectionBase::_onDone - calling disconnected callback
I/flutter (13077): 1-2023-01-19 17:57:32.155270 -- SynchronousMqttServerConnectionHandler::internalConnect - post sleep, state = Connection status is connecting with return code of noneSpecified and a disconnection origin of none
I/flutter (13077): 1-2023-01-19 17:57:32.156238 -- SynchronousMqttServerConnectionHandler::internalConnect - initiating connection try 1, auto reconnect in progress false
I/flutter (13077): 1-2023-01-19 17:57:32.157922 -- SynchronousMqttServerConnectionHandler::internalConnect - secure selected
I/flutter (13077): 1-2023-01-19 17:57:32.158149 -- SynchronousMqttServerConnectionHandler::internalConnect - calling connect
I/flutter (13077): 1-2023-01-19 17:57:32.158387 -- MqttSecureConnection::connect - entered
I/flutter (13077): 1-2023-01-19 17:57:32.613729 -- MqttSecureConnection::connect - securing socket
I/flutter (13077): 1-2023-01-19 17:57:32.613919 -- MqttSecureConnection::connect - start listening
I/flutter (13077): 1-2023-01-19 17:57:32.614181 -- MqttServerConnection::_startListening
I/flutter (13077): 1-2023-01-19 17:57:32.614406 -- SynchronousMqttServerConnectionHandler::internalConnect - connection complete
I/flutter (13077): 1-2023-01-19 17:57:32.614810 -- SynchronousMqttServerConnectionHandler::internalConnect sending connect message
I/flutter (13077): 1-2023-01-19 17:57:32.615069 -- MqttConnectionHandlerBase::sendMessage - MQTTMessage of type MqttMessageType.connect
I/flutter (13077): Header: MessageType = MqttMessageType.connect, Duplicate = false, Retain = false, Qos = MqttQos.atMostOnce, Size = 24
I/flutter (13077): Connect Variable Header: ProtocolName=MQTT, ProtocolVersion=4, ConnectFlags=Connect Flags: Reserved1=false, CleanStart=false, WillFlag=false, WillQos=MqttQos.atMostOnce, WillRetain=true, PasswordFlag=false, UserNameFlag=false, KeepAlive=20
I/flutter (13077): MqttConnectPayload - client identifier is : FlutterThing
I/flutter (13077): 1-2023-01-19 17:57:32.615504 -- SynchronousMqttServerConnectionHandler::internalConnect - pre sleep, state = Connection status is connecting with return code of noneSpecified and a disconnection origin of none
I/flutter (13077): 1-2023-01-19 17:57:34.804402 -- MqttConnectionBase::_onDone - calling disconnected callback
I/flutter (13077): 1-2023-01-19 17:57:37.618472 -- SynchronousMqttServerConnectionHandler::internalConnect - post sleep, state = Connection status is connecting with return code of noneSpecified and a disconnection origin of none
I/flutter (13077): 1-2023-01-19 17:57:37.620211 -- SynchronousMqttServerConnectionHandler::internalConnect - initiating connection try 2, auto reconnect in progress false
I/flutter (13077): 1-2023-01-19 17:57:37.622382 -- SynchronousMqttServerConnectionHandler::internalConnect - secure selected
I/flutter (13077): 1-2023-01-19 17:57:37.623833 -- SynchronousMqttServerConnectionHandler::internalConnect - calling connect
I/flutter (13077): 1-2023-01-19 17:57:37.625868 -- MqttSecureConnection::connect - entered
I/flutter (13077): 1-2023-01-19 17:57:38.088066 -- MqttSecureConnection::connect - securing socket
I/flutter (13077): 1-2023-01-19 17:57:38.088235 -- MqttSecureConnection::connect - start listening
I/flutter (13077): 1-2023-01-19 17:57:38.088324 -- MqttServerConnection::_startListening
I/flutter (13077): 1-2023-01-19 17:57:38.088416 -- SynchronousMqttServerConnectionHandler::internalConnect - connection complete
I/flutter (13077): 1-2023-01-19 17:57:38.088478 -- SynchronousMqttServerConnectionHandler::internalConnect sending connect message
I/flutter (13077): 1-2023-01-19 17:57:38.088553 -- MqttConnectionHandlerBase::sendMessage - MQTTMessage of type MqttMessageType.connect
I/flutter (13077): Header: MessageType = MqttMessageType.connect, Duplicate = false, Retain = false, Qos = MqttQos.atMostOnce, Size = 24
I/flutter (13077): Connect Variable Header: ProtocolName=MQTT, ProtocolVersion=4, ConnectFlags=Connect Flags: Reserved1=false, CleanStart=false, WillFlag=false, WillQos=MqttQos.atMostOnce, WillRetain=true, PasswordFlag=false, UserNameFlag=false, KeepAlive=20
I/flutter (13077): MqttConnectPayload - client identifier is : FlutterThing
I/flutter (13077): 1-2023-01-19 17:57:38.088738 -- SynchronousMqttServerConnectionHandler::internalConnect - pre sleep, state = Connection status is connecting with return code of noneSpecified and a disconnection origin of none
I/flutter (13077): 1-2023-01-19 17:57:40.270702 -- MqttConnectionBase::_onDone - calling disconnected callback
I/flutter (13077): 1-2023-01-19 17:57:43.093511 -- SynchronousMqttServerConnectionHandler::internalConnect - post sleep, state = Connection status is connecting with return code of noneSpecified and a disconnection origin of none
I/flutter (13077): 1-2023-01-19 17:57:43.093757 -- SynchronousMqttServerConnectionHandler::internalConnect failed
I/flutter (13077): MQTT client exception - mqtt-client::NoConnectionException: The maximum allowed connection attempts ({3}) were exceeded. The broker is not responding to the connection request message (Missing Connection Acknowledgement?
I/flutter (13077): 1-2023-01-19 17:57:43.097536 -- MqttConnectionHandlerBase::disconnect - entered
I/flutter (13077): 1-2023-01-19 17:57:43.097810 -- MqttConnectionHandlerBase::_performConnectionDisconnect entered
I/flutter (13077): 1-2023-01-19 17:57:43.100565 -- MqttConnectionKeepAlive::stop - stopping keep alive
I/flutter (13077): ERROR MQTT client connection failed - disconnecting, state is MqttConnectionState.disconnected
I/flutter (13077): Sleeping....
from mqtt_client.
OK, leave the protocol at 3.1.1 and strip down your connect message to its basic form, i.e. remove these -
.withWillRetain()
.withWillQos(MqttQos.atMostOnce);
from mqtt_client.
OK, leave the protocol at 3.1.1 and strip down your connect message to its basic form, i.e. remove these -
.withWillRetain() .withWillQos(MqttQos.atMostOnce);
Hi Steve,
I found out what was happening.
It was an error in the AWS IoT policy. The policy was not allowing the connection.
Thank you for the help finding out the problem!
from mqtt_client.
OK, leave the protocol at 3.1.1 and strip down your connect message to its basic form, i.e. remove these -
.withWillRetain() .withWillQos(MqttQos.atMostOnce);
this fixed my issue, i had mosquitto 2.0.15 on localhost ubuntu 20 without 'will' it works as expected.
from mqtt_client.
please help
from mqtt_client.
Related Issues (20)
- Hot reload causes infinite MQTT connect loop HOT 3
- Connection Lost When App Killed HOT 1
- Failed to connect to mqtt, I donβt know where the problem lies HOT 1
- mqtt sets reconnection timeout to expire HOT 30
- Need shorter timeout when connection can't be established HOT 9
- feat: Added a connection timeout callback HOT 8
- Add Connection Ack message to connection status HOT 1
- MqttBrowserClient with self-signed certificate HOT 1
- How to add proxy to see content in proxy tools like Charles/Proxyman? HOT 1
- retain:true publishing issue (using IoT Core) HOT 3
- Differences in automatic reconnection between IOS and Android HOT 1
- '400 Bad Request' response while connecting with websocket to rabbitmq HOT 3
- How to connect mqtt with socket header options? HOT 3
- mqttjs:client _checkPing :: checking ping... Runs twice in rapid succession some times HOT 1
- How to determine the cause of the disconnect? HOT 1
- Available bytes is less than the message size HOT 4
- error:Bad state: Cannot add new events after calling close HOT 8
- AWS IoT Certificate - Use .bks file certificate HOT 1
- NoConnectionException: Missing Connection Acknowledgement HOT 4
- Ping triggers client.update and brings the same message multiple times HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mqtt_client.