Closed nimengbo closed 7 months ago
You need to set secure to true for secure working you have it set to false
You need to set secure to true for secure working you have it set to false
When i use the [https://github.com/emqx/MQTTX](mqttx client) secure set false means client would not to verify the CA and server,how can i use mqtts when set secure false
You can either use non secure working on the MQTT standard port 1883 or secure working on port 8883 as you are doing.
If you use 1883 set secure to false which is the default, if you use 8883 then set secure to true but your security credentials must be valid at the tls level.
Refer to the examples or read the API docs.
You need to set secure to true for secure working you have it set to false
Thank for suggestion. It's working
I/flutter (15013): 1-2024-02-05 00:36:44.691535 -- Authenticating with username '{username}' and password '{password}' I/flutter (15013): 1-2024-02-05 00:36:44.693278 -- MqttClient::connect - Connection timeout period is 5000 milliseconds I/flutter (15013): 1-2024-02-05 00:36:44.702589 -- MqttClient::connect - keep alive is enabled with a value of 60 seconds I/flutter (15013): 1-2024-02-05 00:36:44.706233 -- MqttConnectionKeepAlive:: Initialised with a keep alive value of 60 seconds I/flutter (15013): 1-2024-02-05 00:36:44.706706 -- MqttConnectionKeepAlive:: Disconnect on no ping response is disabled I/flutter (15013): 1-2024-02-05 00:36:44.716581 -- MqttConnectionHandlerBase::connect - server mqtt.example.com, port 8883 I/flutter (15013): 1-2024-02-05 00:36:44.722277 -- SynchronousMqttServerConnectionHandler::internalConnect entered I/flutter (15013): 1-2024-02-05 00:36:44.723009 -- SynchronousMqttServerConnectionHandler::internalConnect - initiating connection try 0, auto reconnect in progress false I/flutter (15013): 1-2024-02-05 00:36:44.723838 -- SynchronousMqttServerConnectionHandler::internalConnect - insecure TCP selected I/flutter (15013): 1-2024-02-05 00:36:44.725251 -- SynchronousMqttServerConnectionHandler::internalConnect - calling connect I/flutter (15013): 1-2024-02-05 00:36:44.726806 -- MqttNormalConnection::connect - entered I/flutter (15013): 1-2024-02-05 00:36:45.080243 -- MqttServerConnection::_startListening I/flutter (15013): 1-2024-02-05 00:36:45.083166 -- SynchronousMqttServerConnectionHandler::internalConnect - connection complete I/flutter (15013): 1-2024-02-05 00:36:45.083700 -- SynchronousMqttServerConnectionHandler::internalConnect sending connect message I/flutter (15013): 1-2024-02-05 00:36:45.085182 -- MqttConnectionHandlerBase::sendMessage - MQTTMessage of type MqttMessageType.connect I/flutter (15013): Header: MessageType = MqttMessageType.connect, Duplicate = false, Retain = false, Qos = MqttQos.atMostOnce, Size = 0 I/flutter (15013): Connect Variable Header: ProtocolName=MQTT, ProtocolVersion=4, ConnectFlags=Connect Flags: Reserved1=false, CleanStart=true, WillFlag=false, WillQos=MqttQos.atMostOnce, WillRetain=false, PasswordFlag=true, UserNameFlag=true, KeepAlive=60 I/flutter (15013): MqttConnectPayload - client identifier is : mqtt_1707064604505 I/flutter (15013): 1-2024-02-05 00:36:45.124863 -- SynchronousMqttServerConnectionHandler::internalConnect - pre sleep, state = Connection status is connecting with return code of noneSpecified and a disconnection origin of none
I/flutter (15013): 1-2024-02-05 00:36:45.472524 -- MqttConnection::onData I/flutter (15013): 1-2024-02-05 00:36:45.487794 -- MqttServerConnection::_ondata - message is not yet valid, waiting for more data ... I/flutter (15013): 1-2024-02-05 00:36:45.491569 -- MqttConnectionBase::_onDone - calling disconnected callback I/flutter (15013): 1-2024-02-05 00:36:50.132040 -- SynchronousMqttServerConnectionHandler::internalConnect - post sleep, state = Connection status is connecting with return code of noneSpecified and a disconnection origin of none I/flutter (15013): 1-2024-02-05 00:36:50.133572 -- SynchronousMqttServerConnectionHandler::internalConnect - initiating connection try 1, auto reconnect in progress false I/flutter (15013): 1-2024-02-05 00:36:50.134321 -- SynchronousMqttServerConnectionHandler::internalConnect - insecure TCP selected I/flutter (15013): 1-2024-02-05 00:36:50.135262 -- SynchronousMqttServerConnectionHandler::internalConnect - calling connect I/flutter (15013): 1-2024-02-05 00:36:50.136024 -- MqttNormalConnection::connect - entered I/flutter (15013): 1-2024-02-05 00:36:50.681767 -- MqttServerConnection::_startListening I/flutter (15013): 1-2024-02-05 00:36:50.683700 -- SynchronousMqttServerConnectionHandler::internalConnect - connection complete I/flutter (15013): 1-2024-02-05 00:36:50.684787 -- SynchronousMqttServerConnectionHandler::internalConnect sending connect message I/flutter (15013): 1-2024-02-05 00:36:50.685609 -- MqttConnectionHandlerBase::sendMessage - MQTTMessage of type MqttMessageType.connect I/flutter (15013): Header: MessageType = MqttMessageType.connect, Duplicate = false, Retain = false, Qos = MqttQos.atMostOnce, Size = 48 I/flutter (15013): Connect Variable Header: ProtocolName=MQTT, ProtocolVersion=4, ConnectFlags=Connect Flags: Reserved1=false, CleanStart=true, WillFlag=false, WillQos=MqttQos.atMostOnce, WillRetain=false, PasswordFlag=true, UserNameFlag=true, KeepAlive=60 I/flutter (15013): MqttConnectPayload - client identifier is : mqtt_1707064604505 I/flutter (15013): 1-2024-02-05 00:36:50.690587 -- SynchronousMqttServerConnectionHandler::internalConnect - pre sleep, state = Connection status is connecting with return code of noneSpecified and a disconnection origin of none I/flutter (15013): 1-2024-02-05 00:36:50.989468 -- MqttConnection::onData I/flutter (15013): 1-2024-02-05 00:36:50.992254 -- MqttServerConnection::_ondata - message is not yet valid, waiting for more data ... I/flutter (15013): 1-2024-02-05 00:36:50.994184 -- MqttConnectionBase::_onDone - calling disconnected callback I/flutter (15013): 1-2024-02-05 00:36:55.699826 -- SynchronousMqttServerConnectionHandler::internalConnect - post sleep, state = Connection status is connecting with return code of noneSpecified and a disconnection origin of none I/flutter (15013): 1-2024-02-05 00:36:55.700956 -- SynchronousMqttServerConnectionHandler::internalConnect - initiating connection try 2, auto reconnect in progress false I/flutter (15013): 1-2024-02-05 00:36:55.701679 -- SynchronousMqttServerConnectionHandler::internalConnect - insecure TCP selected I/flutter (15013): 1-2024-02-05 00:36:55.702441 -- SynchronousMqttServerConnectionHandler::internalConnect - calling connect I/flutter (15013): 1-2024-02-05 00:36:55.703496 -- MqttNormalConnection::connect - entered I/flutter (15013): 1-2024-02-05 00:36:56.012784 -- MqttServerConnection::_startListening I/flutter (15013): 1-2024-02-05 00:36:56.014858 -- SynchronousMqttServerConnectionHandler::internalConnect - connection complete I/flutter (15013): 1-2024-02-05 00:36:56.016021 -- SynchronousMqttServerConnectionHandler::internalConnect sending connect message I/flutter (15013): 1-2024-02-05 00:36:56.017024 -- MqttConnectionHandlerBase::sendMessage - MQTTMessage of type MqttMessageType.connect I/flutter (15013): Header: MessageType = MqttMessageType.connect, Duplicate = false, Retain = false, Qos = MqttQos.atMostOnce, Size = 48 I/flutter (15013): Connect Variable Header: ProtocolName=MQTT, ProtocolVersion=4, ConnectFlags=Connect Flags: Reserved1=false, CleanStart=true, WillFlag=false, WillQos=MqttQos.atMostOnce, WillRetain=false, PasswordFlag=true, UserNameFlag=true, KeepAlive=60 I/flutter (15013): MqttConnectPayload - client identifier is : mqtt_1707064604505 I/flutter (15013): 1-2024-02-05 00:36:56.021877 -- SynchronousMqttServerConnectionHandler::internalConnect - pre sleep, state = Connection status is connecting with return code of noneSpecified and a disconnection origin of none I/flutter (15013): 1-2024-02-05 00:36:56.320124 -- MqttConnection::onData I/flutter (15013): 1-2024-02-05 00:36:56.323147 -- MqttServerConnection::_ondata - message is not yet valid, waiting for more data ... I/flutter (15013): 1-2024-02-05 00:36:56.324923 -- MqttConnectionBase::_onDone - calling disconnected callback I/flutter (15013): 1-2024-02-05 00:37:01.028300 -- SynchronousMqttServerConnectionHandler::internalConnect - post sleep, state = Connection status is connecting with return code of noneSpecified and a disconnection origin of none I/flutter (15013): 1-2024-02-05 00:37:01.029913 -- SynchronousMqttServerConnectionHandler::internalConnect failed E/flutter (15013): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled 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?
When i call the
connectToServer()
, will connect failed, please help me to find out the problem ? thanks