-
Notifications
You must be signed in to change notification settings - Fork 293
Open
Description
- Arduino board: ESP8266 (LoLin NodeMcu v3)
- Adafruit_MQTT_library: 2.4.2
- MQTT Server: Eclipse mosquitto 2.0.12
Hello, I discovered strange problem during publishing messages. Every first PUBLISH packet gets no response and additionally server closes connection with:
Client 7879f4a.... disconnected due to protocol error.
...when packets are counted from 0. When I set packet_id_counter variable initially to 1 in Adafruit_MQTT::Adafruit_MQTT, everything works OK
Adafruit_MQTT::Adafruit_MQTT(const char *server, uint16_t port, const char *cid,
const char *user, const char *pass) {
servername = server;
portnum = port;
clientid = cid;
username = user;
password = pass;
// reset subscriptions
for (uint8_t i = 0; i < MAXSUBSCRIPTIONS; i++) {
subscriptions[i] = 0;
}
will_topic = 0;
will_payload = 0;
will_qos = 0;
will_retain = 0;
keepAliveInterval = MQTT_CONN_KEEPALIVE;
// changed code
packet_id_counter = 1;
}This is also related to QOS level. packet_id_counter can be set to 0 but only when QOS 0 is used.
I suspect that this is exact same case as described in MQTT docs:
SUBSCRIBE, UNSUBSCRIBE, and PUBLISH (in cases where QoS > 0) Control Packets MUST contain a non-zero 16-bit Packet Identifier [MQTT-2.3.1-1].
Metadata
Metadata
Assignees
Labels
No labels