From 842a5003405392e883a790d4043dc8824f66902c Mon Sep 17 00:00:00 2001 From: kzangeli Date: Sat, 19 Sep 2026 09:36:12 +0200 Subject: [PATCH] fix: doubled slash, a missing comma, and IoT-Agent readiness Three unrelated defects that each stop a reader part-way. 1. A request is written as 'http://localhost:1026//ngsi-ld/v1/entities/' - a doubled slash, from a URL variable that is not there. A strict broker answers 400 rather than treating it as /ngsi-ld/v1/entities/. 2. A payload is missing a comma: "unitCode": "CEL" "observedAt": "2022-03-01T15:00:00.000Z" so the whole entityOperations/update request is rejected as invalid JSON. 3. waitForIoTAgent loops while the HTTP code is 000, i.e. 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. And link-devices itself 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 after provision-devices - and one such reply then kills the script silently, leaving the tutorial stopped at 'Link Devices to Animal entities'. Verified intermittent: the identical payload against the same agent gave exit=52 then exit=0 back to back. Added --retry to those two calls. --- README.md | 4 ++-- link-devices | 4 ++-- services | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 8df77e5..15fa060 100644 --- a/README.md +++ b/README.md @@ -916,7 +916,7 @@ The concise format is also available for the GeoJSON format which can be request ```console curl -G -iX GET \ - 'http://localhost:1026//ngsi-ld/v1/entities/' \ + 'http://localhost:1026/ngsi-ld/v1/entities/' \ -H 'Link: ; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' \ -H 'Accept: application/geo+json' \ -H 'NGSILD-Tenant: openiot' \ @@ -1141,7 +1141,7 @@ curl -iX POST 'http://localhost:1026/ngsi-ld/v1/entityOperations/update?options= "type": "TemperatureSensor", "temperature": { "value": 16, - "unitCode": "CEL" + "unitCode": "CEL", "observedAt": "2022-03-01T15:00:00.000Z" } } diff --git a/link-devices b/link-devices index 2de7b84..11562ac 100755 --- a/link-devices +++ b/link-devices @@ -42,7 +42,7 @@ do fi done -curl -s -o /dev/null -X POST \ +curl -s -o /dev/null --retry 10 --retry-all-errors --retry-delay 10 -X POST \ 'http://iot-agent:4041/iot/devices' \ -H 'Content-Type: application/json' \ -H 'fiware-service: openiot' \ @@ -74,7 +74,7 @@ do fi done -curl -s -o /dev/null -X POST \ +curl -s -o /dev/null --retry 10 --retry-all-errors --retry-delay 10 -X POST \ 'http://iot-agent:4041/iot/devices' \ -H 'Content-Type: application/json' \ -H 'fiware-service: openiot' \ diff --git a/services b/services index 234fdb1..8b29836 100755 --- a/services +++ b/services @@ -125,9 +125,9 @@ waitForMongo () { waitForIoTAgent () { echo -e "\n⏳ Waiting for \033[1;36mIoT-Agent\033[0m to be available\n" - while [ "$(docker run --network fiware_default --rm quay.io/curl/curl:${CURL_VERSION} -s -o /dev/null -w %{http_code} 'http://iot-agent:4041/version')" -eq 000 ] + while ! [ "$(docker inspect --format='{{.State.Health.Status}}' fiware-iot-agent 2>/dev/null)" == "healthy" ] do - echo -e "IoT Agent HTTP state: " $(curl -s -o /dev/null -w %{http_code} 'http://localhost:4041/version') " (waiting for 200)" + echo -e "IoT Agent health: $(docker inspect --format='{{.State.Health.Status}}' fiware-iot-agent 2>/dev/null) (waiting for healthy)" sleep 6 done }