Knowledge Hub

Factora Academy

Knowledge Hub · Courses · IoT.Factora · Technical · 22 min

Register, token, HTTP and MQTT

Lab against a sandbox factory. Do not use shared demo-food tokens in production.

Introduction

What this covers

A lab that registers a device on a sandbox factory and posts the same reading over HTTP and MQTT without double-counting.

Why it matters on the floor

Practising token changes on the shared demo-food plant breaks the next person's demo. A sandbox factory keeps that mistake off the show floor.

By the end you can

  • Create a temperature device on a sandbox factory and send an HTTP reading with a bearer token and a message id
  • Repeat that message id and confirm the count does not increase
  • Publish MQTT to that factory's topic using the device code as the username and the ingest token as the password

About 22 minutes. Prerequisites: Protocol map and Security model, so the topic, the token, and the rate limits are not new.

Lab 1 — ingest

Use a sandbox factory created in ops, not the public demo-food plant, when practising token rotate.

HTTP

  1. Sign in as plant admin.
  2. Registry → add device code LAB-TEMP, type temperature, unit °C.
  3. Copy ingest token.
  4. Send:
curl -X POST https://iot.factoraerp.com/api/ingest \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{"value": 4.2, "messageId": "lab-1"}'
  1. Confirm the reading on the device page. Repeat the same messageId — count must not double.

MQTT

Broker: iot.factoraerp.com:1883 (no TLS claimed).

mqtt pub -h iot.factoraerp.com -p 1883 \
  -u LAB-TEMP -P '<token>' \
  -t factora/<slug>/devices/LAB-TEMP/telemetry \
  -m '{"value": 9.4, "messageId": "lab-mqtt-1"}'

Wrong factory slug in the topic is rejected. Wrong password is rejected.

Paused factory: plant login fails; do not expect ingest as a “feature” for paused tenants.

Walk the screen

Sensor registry for the demo plant, without opening a device token.
Add the lab device on the registry. Do not put the ingest token on a shared screen.
  1. Create a sandbox factory in ops. Do not practise on the shared demo-food plant.
  2. In the sensor registry, add a temperature device with the code you will use as the MQTT username.
  3. Send one HTTP reading with a bearer token and a message id. Confirm it on the device.
  4. Repeat the same message id and confirm the count does not increase.
  5. Publish MQTT to that factory's topic. A wrong slug or a wrong secret is rejected.
  6. Do not expect ingest to be a feature of a paused factory. Plant login already fails there.

Worked example

LAB-TEMP receives value 4.2 with message id lab-1 over HTTP. The second post with lab-1 does not double the count. The MQTT post uses the same device code and a new message id. The registry list is the screenshot to use in class. Do not open the token on a projector.

Common mistakes

  • Rotating a token on the shared demo plant.
  • Changing the message id on a retry and double-counting.
  • Putting the wrong factory slug in the topic and expecting it to land.

Recap

  • Sandbox factory, then register, then HTTP, then MQTT.
  • The same message id must not double the count.
  • The username is the device code. The topic includes the factory slug.

Create a free account or log in to save this lesson on your progress.

Check understanding

Progress is stored in this browser until you log in. Passing is 70%.

1. MQTT username is
2. Port 1883 is documented as MQTT TLS.
3. Repeating the same message id should
4. The shared demo-food plant is the right place to practise token changes.