shamblett / mqtt_client

A server and browser based MQTT client for dart
Other
548 stars 176 forks source link

I' ve tried several times and could not connect the server, it seems that my software is always rejected by the server. Could anybody help me? #416

Closed Linorman closed 1 year ago

Linorman commented 1 year ago

flutter: LogUtil._printLog Log returen! [because isOpenLog: false, TAG: LogUtil: , inProduction: false] flutter: 1-2022-10-14 19:58:37.060811 -- MqttClient::connect - Connection timeout period is 5000 milliseconds flutter: 1-2022-10-14 19:58:37.062819 -- MqttClient::connect - keep alive is enabled with a value of 60 seconds flutter: 1-2022-10-14 19:58:37.063315 -- MqttConnectionKeepAlive:: Initialised with a keep alive value of 60 seconds flutter: 1-2022-10-14 19:58:37.063407 -- MqttConnectionKeepAlive:: Disconnect on no ping response is disabled flutter: 1-2022-10-14 19:58:37.063826 -- MqttConnectionHandlerBase::connect - server broker.emqx.io, port 1883 flutter: 1-2022-10-14 19:58:37.064561 -- SynchronousMqttServerConnectionHandler::internalConnect entered flutter: 1-2022-10-14 19:58:37.064715 -- SynchronousMqttServerConnectionHandler::internalConnect - initiating connection try 0, auto reconnect in progress false flutter: 1-2022-10-14 19:58:37.064891 -- SynchronousMqttServerConnectionHandler::internalConnect - insecure TCP selected flutter: 1-2022-10-14 19:58:37.065158 -- SynchronousMqttServerConnectionHandler::internalConnect - calling connect flutter: 1-2022-10-14 19:58:37.065471 -- MqttNormalConnection::connect - entered flutter: 1-2022-10-14 19:58:38.071844 -- MqttServerConnection::_startListening flutter: 1-2022-10-14 19:58:38.073347 -- SynchronousMqttServerConnectionHandler::internalConnect - connection complete flutter: 1-2022-10-14 19:58:38.073488 -- SynchronousMqttServerConnectionHandler::internalConnect sending connect message flutter: 1-2022-10-14 19:58:38.073685 -- MqttConnectionHandlerBase::sendMessage - MQTTMessage of type MqttMessageType.connect Header: MessageType = MqttMessageType.connect, Duplicate = false, Retain = false, Qos = MqttQos.atMostOnce, Size = 0 Connect Variable Header: ProtocolName=MQTT, ProtocolVersion=3, ConnectFlags=Connect Flags: Reserved1=false, CleanStart=true, WillFlag=true, WillQos=MqttQos.atLeastOnce, WillRetain=false, PasswordFlag=true, UserNameFlag=true, KeepAlive=60 MqttConnectPayload - client identifier is : 111_client flutter: 1-2022-10-14 19:58:38.078546 -- SynchronousMqttServerConnectionHandler::internalConnect - pre sleep, state = Connection status is connecting with return code of noneSpecified and a disconnection origin of none flutter: 1-2022-10-14 19:58:38.438321 -- MqttConnection::onData flutter: 1-2022-10-14 19:58:38.443029 -- MqttServerConnection::_onData - message received MQTTMessage of type MqttMessageType.connectAck Header: MessageType = MqttMessageType.connectAck, Duplicate = false, Retain = false, Qos = MqttQos.atMostOnce, Size = 2 Connect Variable Header: TopicNameCompressionResponse={0}, ReturnCode={MqttConnectReturnCode.unacceptedProtocolVersion} flutter: 1-2022-10-14 19:58:38.444321 -- MqttServerConnection::_onData - message available event fired flutter: 1-2022-10-14 19:58:38.445629 -- MqttConnectionHandlerBase::_connectAckProcessor flutter: 1-2022-10-14 19:58:38.445812 -- MqttConnectionHandlerBase::_connectAckProcessor connection rejected flutter: 1-2022-10-14 19:58:38.445978 -- MqttConnectionHandlerBase::_performConnectionDisconnect entered flutter: 1-2022-10-14 19:58:38.446097 -- MqttConnectionHandlerBase:: cancelling connect timer flutter: 1-2022-10-14 19:58:38.447035 -- MqttConnectionBase::_onDone - calling disconnected callback flutter: 1-2022-10-14 19:58:38.447387 -- SynchronousMqttServerConnectionHandler::internalConnect - post sleep, state = Connection status is disconnected with return code of unacceptedProtocolVersion and a disconnection origin of none flutter: 1-2022-10-14 19:58:38.447478 -- SynchronousMqttServerConnectionHandler::internalConnect - initiating connection try 1, auto reconnect in progress false flutter: 1-2022-10-14 19:58:38.447628 -- SynchronousMqttServerConnectionHandler::internalConnect - calling connect flutter: 1-2022-10-14 19:58:38.447708 -- MqttNormalConnection::connect - entered flutter: 1-2022-10-14 19:58:38.732736 -- MqttServerConnection::_startListening flutter: 1-2022-10-14 19:58:38.733215 -- SynchronousMqttServerConnectionHandler::internalConnect - connection complete flutter: 1-2022-10-14 19:58:38.733456 -- SynchronousMqttServerConnectionHandler::internalConnect sending connect message flutter: 1-2022-10-14 19:58:38.733642 -- MqttConnectionHandlerBase::sendMessage - MQTTMessage of type MqttMessageType.connect Header: MessageType = MqttMessageType.connect, Duplicate = false, Retain = false, Qos = MqttQos.atMostOnce, Size = 65 Connect Variable Header: ProtocolName=MQTT, ProtocolVersion=3, ConnectFlags=Connect Flags: Reserved1=false, CleanStart=true, WillFlag=true, WillQos=MqttQos.atLeastOnce, WillRetain=false, PasswordFlag=true, UserNameFlag=true, KeepAlive=60 MqttConnectPayload - client identifier is : 111_client flutter: 1-2022-10-14 19:58:38.734488 -- SynchronousMqttServerConnectionHandler::internalConnect - pre sleep, state = Connection status is connecting with return code of noneSpecified and a disconnection origin of none flutter: 1-2022-10-14 19:58:39.125740 -- MqttConnection::onData flutter: 1-2022-10-14 19:58:39.126146 -- MqttServerConnection::_onData - message received MQTTMessage of type MqttMessageType.connectAck Header: MessageType = MqttMessageType.connectAck, Duplicate = false, Retain = false, Qos = MqttQos.atMostOnce, Size = 2 Connect Variable Header: TopicNameCompressionResponse={0}, ReturnCode={MqttConnectReturnCode.unacceptedProtocolVersion} flutter: 1-2022-10-14 19:58:39.126408 -- MqttServerConnection::_onData - message available event fired flutter: 1-2022-10-14 19:58:39.126663 -- MqttConnectionHandlerBase::_connectAckProcessor flutter: 1-2022-10-14 19:58:39.126916 -- MqttConnectionHandlerBase::_connectAckProcessor connection rejected flutter: 1-2022-10-14 19:58:39.127086 -- MqttConnectionHandlerBase::_performConnectionDisconnect entered flutter: 1-2022-10-14 19:58:39.127239 -- MqttConnectionHandlerBase:: cancelling connect timer flutter: 1-2022-10-14 19:58:39.127545 -- MqttConnectionBase::_onDone - calling disconnected callback flutter: 1-2022-10-14 19:58:39.127799 -- SynchronousMqttServerConnectionHandler::internalConnect - post sleep, state = Connection status is disconnected with return code of unacceptedProtocolVersion and a disconnection origin of none flutter: 1-2022-10-14 19:58:39.128020 -- SynchronousMqttServerConnectionHandler::internalConnect - initiating connection try 2, auto reconnect in progress false flutter: 1-2022-10-14 19:58:39.128206 -- SynchronousMqttServerConnectionHandler::internalConnect - insecure TCP selected flutter: 1-2022-10-14 19:58:39.128375 -- SynchronousMqttServerConnectionHandler::internalConnect - calling connect flutter: 1-2022-10-14 19:58:39.128621 -- MqttNormalConnection::connect - entered flutter: 1-2022-10-14 19:58:39.468611 -- MqttServerConnection::_startListening flutter: 1-2022-10-14 19:58:39.469074 -- SynchronousMqttServerConnectionHandler::internalConnect - connection complete flutter: 1-2022-10-14 19:58:39.469349 -- SynchronousMqttServerConnectionHandler::internalConnect sending connect message flutter: 1-2022-10-14 19:58:39.469581 -- MqttConnectionHandlerBase::sendMessage - MQTTMessage of type MqttMessageType.connect Header: MessageType = MqttMessageType.connect, Duplicate = false, Retain = false, Qos = MqttQos.atMostOnce, Size = 65 Connect Variable Header: ProtocolName=MQTT, ProtocolVersion=3, ConnectFlags=Connect Flags: Reserved1=false, CleanStart=true, WillFlag=true, WillQos=MqttQos.atLeastOnce, WillRetain=false, PasswordFlag=true, UserNameFlag=true, KeepAlive=60 MqttConnectPayload - client identifier is : 111_client flutter: 1-2022-10-14 19:58:39.470380 -- SynchronousMqttServerConnectionHandler::internalConnect - pre sleep, state = Connection status is connecting with return code of noneSpecified and a disconnection origin of none flutter: 1-2022-10-14 19:58:39.796063 -- MqttConnection::onData flutter: 1-2022-10-14 19:58:39.796504 -- MqttServerConnection::_onData - message received MQTTMessage of type MqttMessageType.connectAck Header: MessageType = MqttMessageType.connectAck, Duplicate = false, Retain = false, Qos = MqttQos.atMostOnce, Size = 2 Connect Variable Header: TopicNameCompressionResponse={0}, ReturnCode={MqttConnectReturnCode.unacceptedProtocolVersion} flutter: 1-2022-10-14 19:58:39.796798 -- MqttServerConnection::_onData - message available event fired flutter: 1-2022-10-14 19:58:39.797057 -- MqttConnectionHandlerBase::_connectAckProcessor flutter: 1-2022-10-14 19:58:39.797330 -- MqttConnectionHandlerBase::_connectAckProcessor connection rejected flutter: 1-2022-10-14 19:58:39.797538 -- MqttConnectionHandlerBase::_performConnectionDisconnect entered flutter: 1-2022-10-14 19:58:39.797705 -- MqttConnectionHandlerBase:: cancelling connect timer flutter: 1-2022-10-14 19:58:39.798015 -- MqttConnectionBase::_onDone - calling disconnected callback flutter: 1-2022-10-14 19:58:39.798263 -- SynchronousMqttServerConnectionHandler::internalConnect - post sleep, state = Connection status is disconnected with return code of unacceptedProtocolVersion and a disconnection origin of none flutter: 1-2022-10-14 19:58:39.798506 -- SynchronousMqttServerConnectionHandler::internalConnect failed

shamblett commented 1 year ago

You seem to be getting an unaccepted protocol version errot make sure the procol version of the client matches that of your broket see the setProtocol API on the client.

Linorman commented 1 year ago

You seem to be getting an unaccepted protocol version errot make sure the procol version of the client matches that of your broket see the setProtocol API on the client.

Thanks for yours quick reply, but I' ve set the protocol to v311, and I use mosquitto as server, so it shouldn't be wrong though. Could you tell me more about it?

shamblett commented 1 year ago

There's not much more the client can tell you, you could try setting the version to 3.1 other than that you need to look at your brokers logs to see why it thinks the protocol is incorrect.

Linorman commented 1 year ago

Ok, thanks. I will check it out.

Linorman commented 1 year ago

There's not much more the client can tell you, you could try setting the version to 3.1 other than that you need to look at your brokers logs to see why it thinks the protocol is incorrect.

I checked the log of mosquitto and I found there's nothing, which means it never received a request from my client software.

shamblett commented 1 year ago

Well, something is sending you a connect ack message with a failure code of unsupported protocol, so maybe you don't have sufficient logging enabled on your mosquitto broker or your not connecting to the broker you think you are.

Linorman commented 1 year ago

Well, something is sending you a connect ack message with a failure code of unsupported protocol, so maybe you don't have sufficient logging enabled on your mosquitto broker or your not connecting to the broker you think you are.

Ok, I still couldn't find out where problems are, but I tried to connect the server by anonymous way and it worked. Thanks for your suggestions.