IMD SolutionComputing LibraryShop main store

How-to

Bridge a cellular tracker's TCP stream into MQTT for AWS IoT Core

Edge computing and IIoT Published 7 min read

Short answer

Build a small ingest service on your edge PC: it terminates the tracker's raw TCP session, decodes each stored record, and republishes one MQTT message per fix over TLS on port 8883. Acknowledge a packet only after every publish is confirmed, or a coverage-gap batch is silently lost.

On this page
  1. Why does a cellular tracker send raw TCP instead of MQTT?
  2. What does the bridge do on each hop?
  3. How do I build the TCP-to-MQTT bridge?
  4. How should the MQTT topics and IoT policy be laid out?
  5. When should the bridge acknowledge a tracker packet?
  6. What breaks first in a TCP-to-MQTT bridge?
  7. How do I verify the bridge end to end?
  8. Questions asked

Most cellular trackers do not speak MQTT. They open a raw TCP socket to a configured server and send a compact binary stream with a count-based acknowledgment, so AWS IoT Core, which a device reaches with MQTT or HTTPS, never sees a handshake it can complete. The answer is a small ingest service: it terminates the tracker's TCP session, decodes each record, and republishes one MQTT message per fix over TLS on port 8883. Deploy it on a fanless mini PC that already runs your plant's gateways, keep the tracker, and you own exactly one new service and its uptime.

Why does a cellular tracker send raw TCP instead of MQTT? #

Because the device class is built for intermittent coverage and store-and-forward batches: a compact binary record with a count-based acknowledgment costs less modem time, battery, and data than holding a TLS session, a keepalive, and a broker identity.

MQTT rides on TCP anyway, so the difference is the framing and the broker exchange, not the transport. What the tracker avoids is everything around it: the handshake, the client identity, keepalive traffic on a metered cellular link, and a session that must be rebuilt after every coverage gap. Telemetry designs often split transport duties further, with UDP carrying the live position stream and an acknowledged TCP protocol carrying commands and backlog delivery, which is the pattern your device follows.

The practical consequence: every operator of this device class runs a receiving server, and the vendor's data-sending protocol document is the authority on packet layout. Take it from the manufacturer before writing the parser. Building the receiver is the normal integration step for this hardware, not a sign of a misconfigured device. So the decision between hunting for a native-MQTT wearable and writing the bridge resolves one way: write the bridge. The wearable rarely exists, and the bridge preserves the store-and-forward behavior that matters when a person crosses a dead zone.

What does the bridge do on each hop? #

It terminates two sessions and translates between them: the tracker's TCP identity exchange on your listening port at one end, and MQTT over TLS on port 8883 into AWS IoT Core at the other, with the decoder in between.

Hop Transport What happens
Tracker to carrier Cellular data Opens a TCP socket to the host, port, and transport set in the device configuration tool.
Carrier to bridge host Inbound TCP Needs a reachable address, a listening port, and a firewall rule that admits the tracker traffic.
Session layer Vendor binary Reads the identity packet, checks it against an allow-list, and replies with the accept message the protocol defines.
Decode layer Parser Extracts timestamp, latitude, longitude, speed, and I/O values per record.
Bridge to AWS IoT Core MQTT over TLS (8883) Publishes JSON under an X.509 client certificate governed by an IoT policy.

One security fact belongs to this table: the inbound TCP leg crosses the public internet unencrypted unless the device offers a secured transport. Allow-list the listener, restrict it to the carrier's address ranges where the APN permits, and treat the device identity in the first packet as a claim to validate, not as authentication.

How do I build the TCP-to-MQTT bridge? #

Eight steps: get the protocol document, register the thing and certificate, write the allow-listed listener, decode and publish per record, acknowledge after confirmation, point the tracker at the host, add the routing rule, then run it as its own process.

  1. Download the tracker's data-sending protocol document from the manufacturer. Record the identity packet format, the data packet framing, the record fields with their units and signedness, and the acknowledgment reply.
  2. In AWS IoT Core, register one thing per tracker if you want per-device policies, or one thing for the bridge if a shared policy is acceptable. Issue the certificate and attach the policy.
  3. Write the TCP listener: accept a connection, read the identity packet, validate it against the allow-list, and send the accept reply the document defines.
  4. Loop on data packets: decode every record, publish one MQTT message per record, then send the acknowledgment with the ordering rule in the next section.
  5. Publish the device's own timestamp with each record, never the server's receive time, so a batch from a coverage gap plots at the right place and time.
  6. Point the tracker at the bridge in its configuration tool: host, port, and TCP as the transport.
  7. Add a rule in IoT Core that routes the messages into storage, such as a time-series table or your plant historian.
  8. Run the listener as its own process or container so a restart never touches the other gateway software on the PC.

Deployed this way, the service sits beside your existing protocol translations, the same pattern as bridging OPC UA PLC data to MQTT with an edge PC: one small service per source protocol.

How should the MQTT topics and IoT policy be laid out? #

One topic per device, one policy bound to one certificate: publish to trackers/{deviceId}/position, and allow the certificate iot:Connect only for the client ID matching its thing name plus iot:Publish only on that device's topic subtree.

That one-topic-per-device shape lets a policy bind each certificate to its own subtree. Register one thing per tracker; a single thing for the whole bridge works, but then every tracker shares one policy and one blast radius. The policy follows the documented pattern: allow iot:Connect when the client ID matches the thing the certificate is attached to, and iot:Publish only on that thing's topics. A rule in IoT Core then routes the messages into storage.

Publish over TLS. If the site's egress policy blocks the MQTT port, AWS IoT Core also accepts an HTTPS publisher on port 443 that sends single messages with no session. The certificate and policy mistakes that break this leg are the same ones that stop X.509 certificate auth to Azure IoT Hub over MQTT, so the same checks apply.

When should the bridge acknowledge a tracker packet? #

Only after the broker confirms the delivery: publish each record at QoS 1, wait for the PUBACK on every message, and only then send the acknowledgment count the protocol defines, and that count must equal the records you actually delivered.

If a publish fails, withhold the acknowledgment or send a reduced count, so the tracker resends what was not confirmed. Ordering the acknowledgment after confirmed publishes is what converts a permanent loss into a resend.

Worked example (illustrative interval): a tracker reports one fix every 60 s. Its wearer crosses a dead zone for 12 min, so the device stores 12 min × 1 fix/min = 12 records and sends them in one packet when coverage returns. Correct sequence: decode 12 records, publish 12 messages, count 12 PUBACKs, acknowledge 12. Acknowledge on receipt instead, with the MQTT side down for records 7 through 12, and the tracker deletes the batch after your premature reply: 12 records − 6 delivered = 6 fixes lost permanently. Acknowledge after confirmation and the same outage costs nothing: the tracker resends the packet, you republish all 12, and the 6 duplicates are dropped on the (deviceId, timestamp) pair.

What breaks first in a TCP-to-MQTT bridge? #

Four faults cover most outages: the tracker never reaches the listener, the session drops after the first packet, records repeat, or records never reach the cloud, and each points at one specific hop.

Symptom Likely cause Check
Tracker never appears at the server Port unreachable, wrong address, APN blocking Packet capture on the listening port: a SYN with no reply is a firewall or routing fault; no SYN means the tracker is not dialing.
Session opens, then drops after the first packet Identity reply missing or wrong Compare the bytes your server returns against the protocol document.
The same records arrive repeatedly Acknowledgment count wrong or late Log records received and records acknowledged per packet; they must match.
Records missing in the cloud Acknowledged before the publish succeeded Reorder so the acknowledgment follows the confirmed publish.
MQTT connect refused Policy denies the client ID, or the certificate is not attached or active Compare the policy's resource with the client ID the bridge presents.
Coordinates or speed off by a scale factor Field units or signedness misread Compare one decoded record against the vendor's configuration tool at the same timestamp.

How do I verify the bridge end to end? #

Four checks prove it: a capture on the listener, a message seen in the broker's test client, one record matched against the vendor's own tool, and a walk through a dead zone with nothing lost.

  • Capture traffic on the bridge host and confirm the tracker connects, sends the identity packet, and receives your reply.
  • Subscribe to trackers/# in the AWS IoT Core MQTT test client and confirm one message arrives per record.
  • Compare one decoded latitude, longitude, speed, and timestamp against the same record in the manufacturer's configuration tool.
  • Take the tracker out of coverage for several minutes, return, and confirm every stored record arrives exactly once with its original timestamp.

Questions asked

Can a cellular tracker publish to AWS IoT Core directly?

Not this class of device. It opens a raw TCP socket and sends a vendor binary format, while AWS IoT Core terminates MQTT and HTTPS connections, so no handshake completes. Some newer trackers ship native MQTT clients; confirm that from the vendor's datasheet before purchase, because a product page silent on MQTT is not confirmation.

How many MQTT messages will one tracker generate per day?

At one fix every 60 s, one tracker publishes 86,400 s ÷ 60 s = 1,440 messages per day. Size the storage behind your routing rule on that figure and multiply by fleet size: 40 trackers produce 57,600 messages per day.

Why do the same positions arrive twice in the cloud?

Because the bridge acknowledges only after confirmed publishes, a packet whose MQTT side fails is resent whole, so records that did land arrive again. Deduplicate on device identity plus record timestamp before the values reach the historian or a dashboard; the duplicates are the deliberate price of never losing a batch.

Would a LoRaWAN badge avoid the bridge entirely?

Only where gateway coverage follows every route. A LoRaWAN tracker delivers through a gateway and network server that republish to MQTT, which suits a fixed site well. For people walking public roads, private gateways cannot follow them, so cellular plus the bridge remains the working choice.

Does the bridge need its own computer?

No sizing case exists: the service is one listening socket plus a few publishes per minute per tracker, so the industrial PC already running your plant gateways carries it. Run the listener as its own process or container so a crash and restart never touches the gateway software beside it.

Keep reading

  • How-to

    Bridging OPC UA PLC data to MQTT with an edge PC

    Keep the OPC UA server on the PLC side and give MQTT publishing its own role on a separate edge PC that acts as the OPC UA client and MQTT publisher. Commission the two links independently — first a verified tag read, then a verified subscriber message — and only then widen the tag set.

    Edge computing and IIoT

  • How-to

    Sending PLC data to an IoT hub without custom software

    You do not need custom software to move PLC data to an IoT hub: a configurable edge package with an S7, Modbus TCP or EtherNet/IP driver, a channel mapping and an MQTT publisher replaces hand-written acquisition code. Verify two things before you commit: the driver covers the protocol your controller actually speaks, and the publisher covers the destination's authentication and message format. Software still does the work — you configure it instead of writing it.

    Edge computing and IIoT

  • Comparison

    PLC MQTT direct publishing versus an IoT gateway

    For publishing process data to an MQTT broker for web monitoring, put the MQTT client in a gateway and leave the S7-1500 out of broker session logic. Keep the LMQTT_Client block in the PLC only when publication must be coordinated with control logic or the gateway cannot meet your topic, payload and delivery requirements. A green MQTT status proves the broker connection only, never the S7 data behind it.

    Edge computing and IIoT