Open AizenvoltPrime opened 2 hours ago
That sounds like an old issue Infixed some time ago. Is it an entity that is registered "elsewhere" but doesn't exist locally?
What is the tag of the broker? (not clear ...)
No, just think of the example I gave you on the subscriptions issue, where you skip the entity creation and subscription requests and just do the add data when the entity and subscriptions dont exist yet. In the app I am developing I have made a frontend form for users to create orion entities for iot devices dynamically and I discovered that issue in the process of developing the app. I don't think that it was intended for the container to crash if somehow, because of a bug in code a wrong post request was made.
Ok. There is a known bug in the "/attrs" service. I haven't spent any time on it as that API endpoint is to be deprecated soon (the sooner the better).
Try PATCH /entities/[entityId]. Definitely preferable. Also, if you can, please stop using application/ld+json. It only gives the broker unnecessary work and extra code to execute
Ok I will try to add data using PATCH then. In regards to the application/ld+json, I tried doing something like
curl --location 'http://SERVER_IP:1026/ngsi-ld/v1/entities/' \
--header 'Content-Type: application/json' \
--header 'NGSILD-Tenant: openiot' \
--header 'Link: <https://mysite.com/api/ngsi-ld-attributes>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' \
--data '{
"id": "urn:ngsi-ld:test_entity_id2",
"type": "test_entity_type",
"temperature": {
"type": "Property",
"value": 23.4
}
}'
the link has content like:
{
"@context": {
"attributes": "https://mysite.com/api/ngsi-ld-attributes/",
"temperature": { "@id": "attributes:temperature", "@type": "xsd:float", "unit": "°C", "en": "Temperature", "el": "Θερμοκρασία" },
"humidity": { "@id": "attributes:humidity", "@type": "xsd:integer", "unit": "%", "en": "Humidity", "el": "Υγρασία" }
}
}
but the entities dont get saved correctly in mongo. They look like:
{
"_id": {
"id": "urn:ngsi-ld:test_entity_id",
"type": "https://uri.etsi.org/ngsi-ld/default-context/test_entity_type",
"servicePath": "/"
},
"attrNames": [
"https://uri.etsi.org/ngsi-ld/attributestemperature"
],
"attrs": {
"https://uri=etsi=org/ngsi-ld/attributestemperature": {
"type": "Property",
"creDate": 1732901606.1755981,
"modDate": 1732901606.1755981,
"value": 23.4,
"mdNames": []
}
},
"creDate": 1732901606.1755981,
"modDate": 1732901606.1755981,
"lastCorrelator": ""
}
when they should be like:
{
"_id": {
"id": "urn:ngsi-ld:test_entity_id",
"type": "https://uri.etsi.org/ngsi-ld/default-context/test_entity_type",
"servicePath": "/"
},
"attrNames": [
"https://mysite.com/api/ngsi-ld-attributes/temperature"
],
"attrs": {
"https://mysite=com/api/ngsi-ld-attributes/temperature": {
"type": "Property",
"creDate": 1732901686.2456894,
"modDate": 1732901686.2456894,
"value": 23.4,
"mdNames": []
}
},
"creDate": 1732901686.2456894,
"modDate": 1732901686.2456894,
"lastCorrelator": ""
}
which is done with the initial way I create entities that I showed in the example above.
Also for the variables in docker compose: ORION_LD_PORT=1026 ORION_LD_VERSION=1.7.0 QUANTUMLEAP_VERSION=1.0.0 QUANTUMLEAP_PORT=8668 CRATE_VERSION=latest MONGO_DB_PORT=27017 MONGO_DB_VERSION=latest REDIS_PORT=6380 REDIS_VERSION=6 for REDIS_USERNAME and REDIS_PASSWORD put whatever
If you just start all the containers and then try to add data to an entity that doesnt exist the orion container crashes. You could say I could run a cron job to check if the orion container stopped working for some reason and work around this issue but I dont think the intended functionality is for the container to crash every time someone does a wrong request. This was how I discovered the other issue with subscriptions I posted last week.