Discuss here different C compiler set ups, and compiling executables for the ESP8266

User avatar
By trendchaster
#30938 Hello folks,
I am working on MQTT code(tuanpmt ) and I want to disconnect the MQTT after the data is being post to broker via Mosquitto to the server.
MQTT: Sending, type: 3, id: 0000
TCP: Sent
MQTT: Published
MQTT: Sending, type: 3, id: 0000
TCP: Sent
MQTT: Published
MQTT: Sending, type: 3, id: 0000
TCP: Sent
MQTT: Published
MQTT: Sending, type: 3, id: 0000
TCP: Sent
MQTT: Published

MQTT: Send keepalive packet to 10.10.10.127:1883!
MQTT: Sending, type: 12, id: 0000
TCP: Sent
TCP: data received 2 bytes
TCP: Disconnected callback
MQTT: Disconnected

After it mentioning disconnect on console it again transmit the same data and it goes on continously.I want to disconnect it and continue to main loop.How it can be possible?
User avatar
By Cicero
#48001 Hi trendchaster...

Did you ever manage to do a controlled disconnect?

When I run mqtt-spy with wireshark and disconnect, it sends one PSH,ACK packet, followed directly with a FIN,ACK. To which the server responds with a FIN,ACK, and ACK.

The PSH,ACK packet has a data field of 0xE000.

So I presume it needs that same type of disconnect structure?
User avatar
By Cicero
#48047 Just a bit of extra info from my side...

A 0x0E (14) is a MQTT_MSG_TYPE_DISCONNECT message.

If I send that to the server, I get a FIN,ACK directly back. FIN,ACKing that and get an ACK back.

...but, if I try to reconnect directly after that, sending a SYN packet, I get just an ACK back instead of the expected SYNACK. Like its kept the connection open? Very annoying.