โ† Back to the chapter

Technical detail ยท Practice: Mobile Gateway Protocols

Why reconnect needs record identity and bounded storage

Draining the buffer on reconnect is deceptively hard. If the gateway uploads a batch and the link drops before the acknowledgment arrives, it cannot tell whether the server received the batch. Re-sending on the next reconnect provides at-least-once delivery: the record may be delivered more than once. Not re-sending risks loss. The fix is to tag each record with a sequence number that increases with each new record (a monotonic sequence number), or a message id so the server can deduplicate, turning at-least-once transport into effectively-once storage. Order matters too: a naive drain that interleaves retries with fresh data can deliver records out of sequence.

An unbounded queue can grow during a long outage until memory runs out. A bound limits queue growth, but other memory use can still crash the process. When the queue is full, a design may block the producer, report failure, or drop records under a chosen policy. Flash can extend storage but also has a limit. Record queue depth, blocked or failed writes, and any drops. State the full-queue action in the contract so a gap leaves evidence.

Reconnect also creates timing problems. Sensor time, gateway receipt time, queue enqueue time, upload attempt time, and server acceptance time can all differ by minutes. The cloud should not overwrite source time with upload time, and analytics should know whether a record was fresh, stale-but-useful, or rejected as too old. Release evidence must cover lost acknowledgements, out-of-order drain, full-buffer behavior, and stale-record rejection.

โ† Back to the chapter