Von English mit KI übersetzt ·
Ich habe das letztes Jahr an unseren Anhänger-Trackern gemessen, weil unsere Mobilfunkrechnung absurd war. Grobe Werte aus Paketmitschnitten auf einem SIM7600, TLS 1.2, dem Broker der Plattform:
- vollständige Neuverbindung (TCP- + TLS-Handshake mit Zertifikatskette + CONNECT + SUBSCRIBEs): etwa 5 bis 6 KB
- ein Keepalive-Roundtrip (PINGREQ/PINGRESP innerhalb von TLS, dazu TCP/IP-Header und ACKs): ungefähr 150 bis 200 Byte
- Ihr 80-Byte-Messwert als QoS-1-Publish innerhalb von TLS mit PUBACK: ebenfalls ein paar hundert Byte
Eine Neuverbindung alle 5 Minuten würde also etwa 8.640 Handshakes im Monat kosten, 45+ MB. Deutlich schlechter. Keepalive 60 ergibt 43.200 Pings im Monat, rund 8 MB. Das ist ein großer Teil Ihrer 25 MB.Was bei uns funktioniert hat:Keepalive bis 300 s (der Broker setzt alles darüber ohnehin auf 300). Das reduziert die Pings auf ein Fünftel. Prüfen Sie, ob Ihr Provider inaktive NAT-Sitzungen nicht schneller trennt; bei uns hielten 6 Minuten, bei manchen werden sie nach 2 bis 4 Minuten getrennt. Wenn Sie keepalive_timeout im Log-Tab des Geräts sehen, senken Sie den Wert.Batching. Statt alle 5 Minuten einen Publish zu senden, puffern Sie 3 Messwerte und senden sie als ein Array mit Zeitstempeln (der ESP32 hat NTP, daher ist ts unproblematisch):
[{"ts":1762336800000,"values":{"flow":12.1,"pressure":2.4,"pump":1}},
{"ts":1762337100000,"values":{"flow":12.3,"pressure":2.4,"pump":1}},
{"ts":1762337400000,"values":{"flow":11.9,"pressure":2.3,"pump":1}}]
Gleiche Daten, ein Publish, und es zählt zudem als eine Nachricht auf das Monatskontingent statt drei.Suchen Sie nach unnötigem Datenverkehr. Bei uns war das Schlimmste, dass die Firmware bei jedem Publish Client-Attribute (IP, RSSI, Firmware-Version) mitgeschickt hat. Senden Sie diese nur bei Änderung.Zum Offline-Status: Mit Live connection als Online-Regel bleiben die Geräte online, solange die MQTT-Sitzung offen ist, bei Keepalive 300 ändert sich also nichts. Falls Sie jemals auf Verbinden-Senden-Trennen umstellen, wechseln Sie zu einem Profil mit Recent message, sonst werden sie zwischen den Sendungen als offline angezeigt.
I measured this on our trailer trackers last year because our carrier bill was silly. Rough numbers from packet captures on a SIM7600, TLS 1.2, the platform’s broker:
- full reconnect (TCP + TLS handshake with certificate chain + CONNECT + SUBSCRIBEs): about 5 to 6 KB
- one keepalive round trip (PINGREQ/PINGRESP inside TLS, plus TCP/IP headers and ACKs): roughly 150 to 200 bytes
- your 80-byte reading as a QoS 1 publish inside TLS with PUBACK: also a couple of hundred bytes
So reconnecting every 5 minutes would cost about 8,640 handshakes a month, 45+ MB. Way worse. Keepalive 60 is 43,200 pings a month, around 8 MB. That’s a big chunk of your 25 MB.
What worked for us:
Keepalive up to 300 s (the broker serves anything above its maximum at 300 anyway). That cuts pings by five. Check your carrier doesn’t drop idle NAT sessions faster; ours held 6 minutes, some drop at 2 to 4. If you see keepalive_timeout in the device’s Log tab, step it down.
Batch. Instead of one publish every 5 minutes, buffer 3 readings and send them as one array with timestamps (ESP32 has NTP, so ts is fine):
[{"ts":1762336800000,"values":{"flow":12.1,"pressure":2.4,"pump":1}},
{"ts":1762337100000,"values":{"flow":12.3,"pressure":2.4,"pump":1}},
{"ts":1762337400000,"values":{"flow":11.9,"pressure":2.3,"pump":1}}]
Same data, one publish, and it also counts as one message against the monthly quota instead of three.
Look for chatty extras. In our case the worst was the firmware sending client attributes (IP, RSSI, firmware version) on every publish. Only send them on change.
On offline: with Live connection as the online rule they stay online as long as the MQTT session is open, so with keepalive 300 nothing changes. If you ever do go connect-send-disconnect, switch them to a profile with Recent message, otherwise they’d show offline between sends.

