Closed Abenstex closed 2 years ago
BTW, I am getting the same debug output when I use 'ws://test.mosquitto.org' and port 8080 or 8081. So I don't think it has anything to do with my internal mosquitto setup especially because I can connect using other applications. I am using version 9.6.1 by the way.
Run the at the mqtt_browser_client.dart example from the examples directory, this is known to work, see what that gives.
I ran the browser client example, but still got the same output:
1-2021-11-16 10:50:29.782 -- SynchronousMqttBrowserConnectionHandler::internalConnect - pre sleep, state = Connection status is connecting with return code of noneSpecified and a disconnection origin of none
1-2021-11-16 10:50:34.809 -- SynchronousMqttBrowserConnectionHandler::internalConnect - post sleep, state = Connection status is connecting with return code of noneSpecified and a disconnection origin of none
1-2021-11-16 10:50:34.809 -- SynchronousMqttBrowserConnectionHandler::internalConnect - initiating connection try 2, auto reconnect in progress false
1-2021-11-16 10:50:34.809 -- SynchronousMqttBrowserConnectionHandler::internalConnect - calling connect
1-2021-11-16 10:50:34.810 -- MqttBrowserWsConnection::connect - entered
1-2021-11-16 10:50:34.810 -- MqttBrowserWsConnection::connect - WS URL is ws://test.mosquitto.org:8080
1-2021-11-16 10:50:34.810 -- MqttBrowserWsConnection::connect - connection is waiting
1-2021-11-16 10:50:34.885 -- MqttBrowserWsConnection::connect - websocket has erred
1-2021-11-16 10:50:34.885 -- SynchronousMqttBrowserConnectionHandler::internalConnect - connection complete
1-2021-11-16 10:50:34.885 -- SynchronousMqttBrowserConnectionHandler::internalConnect sending connect message
1-2021-11-16 10:50:34.885 -- MqttConnectionHandlerBase::sendMessage - MQTTMessage of type MqttMessageType.connect
Header: MessageType = MqttMessageType.connect, Duplicate = false, Retain = false, Qos = MqttQos.atMostOnce, Size = 63
Connect Variable Header: ProtocolName=MQIsdp, ProtocolVersion=3, ConnectFlags=Connect Flags: Reserved1=false, CleanStart=true, WillFlag=true, WillQos=MqttQos.atLeastOnce, WillRetain=false, PasswordFlag=false, UserNameFlag=false, KeepAlive=20
MqttConnectPayload - client identifier is : Mqtt_MyClientUniqueId
1-2021-11-16 10:50:34.886 -- SynchronousMqttBrowserConnectionHandler::internalConnect - pre sleep, state = Connection status is connecting with return code of noneSpecified and a disconnection origin of none
1-2021-11-16 10:50:39.891 -- SynchronousMqttBrowserConnectionHandler::internalConnect - post sleep, state = Connection status is connecting with return code of noneSpecified and a disconnection origin of none
1-2021-11-16 10:50:39.892 -- SynchronousMqttBrowserConnectionHandler::internalConnect failed
EXAMPLE::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?
1-2021-11-16 10:50:39.895 -- MqttConnectionHandlerBase::disconnect - entered
1-2021-11-16 10:50:39.896 -- MqttConnectionHandlerBase::_performConnectionDisconnect entered
1-2021-11-16 10:50:39.897 -- MqttConnectionKeepAlive::stop - stopping keep alive
EXAMPLE::OnDisconnected client callback - Client disconnection
EXAMPLE::OnDisconnected callback is solicited, this is correct
EXAMPLE::ERROR Mosquitto client connection failed - disconnecting, status is Connection status is disconnected with return code of noneSpecified and a disconnection origin of solicited
EXAMPLE::OnDisconnected client callback - Client disconnection
EXAMPLE::OnDisconnected callback is solicited, this is correct
I thought that maybe the problem could have something with the browser setting, so I set the security level to "insecure" allowing all kind of connections, but that didn't solve the problem unfortunately.
Try this -
client.websocketProtocols = MqttClientConstants.protocolsSingleDefault;
i.e manually set the WS headers the client sends to mosquito. If this works I'll update the example, I'm sure mosquito didn't need this at one time, other brokers do though.
Thank you! That solved the problem
Browser client example updated, package re released at version 9.6.2.
Hello everyone,
I've been struggling a lot to get mqtt up and running with Flutter. I've been using it with Golang and Javascript for a while, but currently I'm at a loss in Flutter. My code is the following:
However I keep seeing this error message in the mosquitto log file:
Socket error on client <unknown>, disconnecting.
My mosquitto config is as follows:The debug output:
What am I missing? Why is it client unknown even though I specified a client id?