Closed Tate-zwt closed 2 years ago
I'm not sure what your issue is here, this is normal client/server behavior, you connect to the server(MQTT broker in your case) on a known port and the server allocates a port for your client to use, this will be different every time you connect(and across all other connected clients). Normally you do not need to know any of this as the platform network stack handles all this for you.
The exception you are seeing is not raised by the client, its raised by the Dart/flutter runtime so it contains what it contains, I can't affect this at all.
Thank you for your reply, will this exception affect receiving messages? MQTT is used on Andorid and iOS, and the environment used is the mobile network. Is it abnormal due to poor network?
Well yes its an exception so if you don't handle it the client will exit, the error you are seeing is usually caused by the client socket being closed wither by the broker or the network layer so it could be down to poor connectivity.
ok thanks for your reply !
When running online, the exception information will be captured, but the port number will be different each time the error is reported. I set the port number to connect to the default MqttClientConstants.defaultMqttPort(port:1883). I thought it was a problem with the automatic reconnection at first, and the automatic reconnection was turned off. but this abnormal information will still be reported. I don't know how to deal with it. Occasionally, in the online environment, the information that MQTT cannot be obtained 。 I hope to get your reply. Thank you! version:mqtt_client: ^9.6.5
connection code: