Hi all,
I'm having trouble with the MQTT client on the Uno WiFi Developer Edition. It can't keep a connection alive (logs below), and messages for subscriptions are never delivered. I've tried this with a few different brokers now, and they all exhibit the same problem.
Logs from the board:
8171> MQTT: TCP connected to m20.cloudmqtt.com:18462
8171> MQTT: Send type=TYPE_CONNECT id=0000 len=40
8210> MQTT: Send type=SUBSCRIBE id=0001 len=10
8212> MQTT: Recv type=CONNACK id=0000 len=4; Pend type=SUBSCRIBE id=01
8305> MQTT: Recv type=SUBACK id=0001 len=5; Pend type=SUBSCRIBE id=01
10444> Thu Feb 09 13:12:30 2017
10444>
12464> MQTT: Recv type=PUBLISH id=0000 len=8; Pend type=NULL id=00
12464> MQTT: Recv PUBLISH qos=0 v/ba
15089> Wifi check: mode=AP+STA status=5
32436> MQTT: Connect to m20.cloudmqtt.com:18462 0x3fff91a8
32492> MQTT: ip 54.228.205.206
32492> MQTT: connecting...
32529> MQTT: TCP connected to m20.cloudmqtt.com:18462
32529> MQTT: Send type=TYPE_CONNECT id=0000 len=40
32574> MQTT: Disconnect CB, freeing espconn 0x3fff8f58
32574> MQTT: Disconnected from m20.cloudmqtt.com:18462
32575> MQTT ERROR: recv in invalid state 1
32575> MQTT: Disconnecting from m20.cloudmqtt.com:18462 (0x3fff91a8)
32576> MQTT: Disconnect CB, freeing espconn 0x3fff91a8
The code that queries the MQTT status is relatively trivial (excerpt below):
if (current - msg_last_check >= MSG_INTERVAL) {
CiaoData packet = Ciao.read(MSG_PROTOCOL, MSG_RECEIVE);
if (!packet.isEmpty()) {
String status = packet.get(2);
#ifdef DEBUG
Serial.print("loop: received status '");
Serial.print(status);
Serial.print("' from server.\n");
#endif
}
}
Has anybody encountered this issue, or managed to bypass it? It's looking like the MQTT client implementation on the ESP8266 coprocessor is flawed, but if the problem is anywhere in my setup, that'd be great.