Resultados de
Hi... I managed to work out both the pub & sub parts of MQTT with my esp8266. I did the example from over here ... and all works fine. The publishing happens every 15secs... and it received the published values back almost immediately. see Img1.png
Now using flutter from my mobile app I did the same thing... and I was able to pub & sub... and also checked the Field1 values in my Thingspeak account that i am writing to and reading as an MQTTclient. It all works correctly.
HOWEVER... heres the problem================ When I only publish from the mobile a value for Field1. And subscribing at the same time from my esp8266 to receive the updated value of Field1... something weird happens... My Field1 in the channel, in my Thingspeak account has been updated correctly... but my esp8266 doesnt receive the updated value. INSTEAD, at the same time I can see in the serial monitor logs, the esp8266 reconnects back to our MQTT server!! No update was received. It felt as if everytime I published a value from my mobile, it made my esp8266 disconnect and hence it needed to reconnect to the MQTT server. i checked this 10 times and it happened without a coincidence. I ran the same code on the esp8266, except that I never let it publish every 15secs. So all it did was stay subscribed and await an update from my mobile app. please see img2.png
and this is the flutters connection code
client.logging(on: false); client.setProtocolV311(); client.keepAlivePeriod = 10; client.onDisconnected = onDisconnected; //....callbacks client.onConnected = onConnected; //....callbacks client.pongCallback = pong; //....callbacks
final connMess = MqttConnectMessage() .withClientIdentifier('xxxxxxxxxxxxxxxx') .withWillTopic('willtopic') // If you set this you must set a will message .withWillMessage('My Will message') .startClean() // Non persistent session for testing .authenticateAs('xxxxxxxxxxxxxxxx', 'aaaaaaaaaaaa') .withWillQos(MqttQos.atMostOnce); // means = 0 print('client connecting....');
Any help will be appreciated. Just wanted to iterate that individually they both work fine. Just that i need the updated value... and i dont receive it. Any ideas?? thanks, YOhan