shamblett / mqtt_client

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

Unable to establish data transfer and communication between two Flutter apps #469

Closed WeiFangChou closed 1 year ago

WeiFangChou commented 1 year ago

I am attempting to establish data transfer and communication between two Flutter apps, but I am unable to receive any data successfully. I have verified that both apps are successfully connected and can communicate with each other using the tools available. However, when attempting to exchange data between the two Flutter apps, no data is being received.

shamblett commented 1 year ago

Not sure what you are trying to do here, you don't explain what 'successfully connected' means nor what 'the tools available' means.

MQTT is a broker based protocol, i.e. you need an MQTT broker running somewhere, your apps use the MQTT client to connect to the broker and exchange messages between themselves via the broker.

You cannot connect applications together using MQTT clients alone. Please read the MQTT spec or look at some of the examples in the examples directory in the repository.

WeiFangChou commented 1 year ago

I am currently working on two Flutter chat apps that are intended to function as chat applications using MQTT for communication. However, I am facing an issue where the two apps are unable to communicate with each other using MQTT. Strangely, each app can successfully communicate with the MQTTX tool individually.

shamblett commented 1 year ago

What is the MQTTX tool? Which MQTT broker are you using?

WeiFangChou commented 1 year ago

Title: Unable to establish communication between two Flutter apps using MQTT

Description: I have developed two Flutter apps that can communicate via MQTT. However, I'm encountering an issue where each app can only communicate with the MQTTX testing tool, but not with each other.

Steps to reproduce:

Set up two Flutter apps with MQTT communication capabilities. Configure the MQTT broker details (hostname, port, authentication) in both apps. Establish MQTT connections in both apps using unique client IDs. Subscribe to and publish messages using MQTT topics in each app. Attempt to send messages between the two apps. Expected behavior: The two Flutter apps should be able to establish MQTT communication and exchange messages with each other.

Actual behavior: Despite the correct MQTT broker configuration and unique client IDs, the two Flutter apps fail to communicate directly. They can only communicate with the MQTTX testing tool individually.

Additional information:

I have verified that the MQTT broker settings are identical in both apps. I have checked the topic subscriptions and message publishing configurations in each app. There are no firewall or network restrictions affecting the MQTT communication. The MQTTX testing tool works fine with both apps, indicating that the apps' MQTT functionality is functional. Please provide guidance or suggestions on how to resolve this issue and enable communication between the two Flutter apps. Thank you.

WeiFangChou commented 1 year ago

Solution I found MqttConnectMessage() use same clientID