Skip to content

Wait for the IoT-Agent to be ready, and retry the device batches - #17

Merged
jason-fox merged 1 commit into
FIWARE:NGSI-LDfrom
kzangeli:fix/iot-agent-readiness
Sep 21, 2026
Merged

jason-fox merged 1 commit into
FIWARE:NGSI-LDfrom
kzangeli:fix/iot-agent-readiness

Conversation

@kzangeli

Copy link
Copy Markdown

This tutorial cannot currently be started: it stops at ⏳ Link Devices to Animal entities and never reaches its first step. Two separate causes.

1. waitForIoTAgent stops waiting too early

while [ "$(docker run … -w %{http_code} 'http://iot-agent:4041/version')" -eq 000 ]

It waits only while the code is 000 (nothing listening), so it stops as soon as the port answers anything — including the 503 the agent serves while still initialising. provision-devices and link-devices then run against an agent that isn't ready.

IoT-Agent, IoT-Agent-JSON and Big-Data-Spark already wait on the container health status instead; this brings it into line.

2. link-devices has no retry, under set -e

It POSTs several ~30 KB device batches. The agent intermittently closes the connection without replying — curl exit 52, "empty reply from server" — most often on the batch immediately following provision-devices. Because the script runs under set -e, one such reply kills it silently, with no error shown to the reader.

⭐ Verified intermittent rather than assumed: the identical payload against the same agent gave exit=52 then exit=0 back to back. A single device is accepted with 201 throughout, and 31 KB is nowhere near the agent's 1 MB expressLimit, so it isn't a size limit.

--retry 10 --retry-all-errors --retry-delay 10 on those two calls. Tested end-to-end: with only this change the tutorial starts cleanly (services exits 0) and its steps run.

Found while running all sixteen NGSI-LD tutorials against a different NGSI-LD broker — this was one of four that could never be started.

waitForIoTAgent loops while the HTTP code is 000, so it stops waiting as soon
as the port answers ANYTHING - including the 503 the agent serves while still
initialising. link-devices then runs against an agent that is not ready.
IoT-Agent, IoT-Agent-JSON and Big-Data-Spark already wait on the container
health status; this brings it into line.

link-devices also POSTs several ~30 KB device batches with no retry, under
'set -e'. The agent intermittently closes the connection without replying
(curl exit 52, 'empty reply from server'), most often on the batch immediately
following provision-devices - and one such reply kills the script silently,
leaving the tutorial stopped at 'Link Devices to Animal entities' with no
error shown.

Verified intermittent: the identical payload against the same agent gave
exit=52 then exit=0 back to back, and a single device is accepted with 201
throughout, so it is not a size limit (31 KB against a 1 MB expressLimit).

With --retry on those two calls the tutorial starts cleanly.
@jason-fox
jason-fox merged commit a3e661f into FIWARE:NGSI-LD Sep 21, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants