1,014 B
Memory management
AsyncMqttClient does not use an internal buffer, it uses the raw TCP buffer.
The max receive size is about 1460 bytes per call to your onMessage callback. But the amount of data you can receive is unlimited, as if you receive, say, a 300kB payload (such as an OTA payload), then your onMessage
callback will be called about 200 times, with the according len, index and total parameters. Keep in mind the library will call your onMessage
callbacks with the same topic buffer, so if you change the buffer on one call, the buffer will remain changed on subsequent calls.
You can send data as long as you stay below the available TCP window (which is about 3-4kB on the ESP8266). The data is indeed held in memory by the async TCP code until ACK is received. If the TCP window was sufficient to send your packet, the publish
method will return a packet ID indicating the packet was sent. Otherwise, a 0
will be returned, and it's your responsability to resend the packet with publish
.