[ https://jira.fiware.org/browse/HELP-13270?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Jose Manuel Cantera reassigned HELP-13270: ------------------------------------------ Assignee: Jose Gato Luis (was: Jose Manuel Cantera) > [fiware-stackoverflow] Orion CB doesn't handle IoT agent replies > -------------------------------------------------------------------- > > Key: HELP-13270 > URL: https://jira.fiware.org/browse/HELP-13270 > Project: Help-Desk > Issue Type: Monitor > Components: FIWARE-TECH-HELP > Reporter: Backlog Manager > Assignee: Jose Gato Luis > Labels: fiware, fiware-orion > > Created question in FIWARE Q/A platform on 03-01-2018 at 14:01 > {color: red}Please, ANSWER this question AT{color} https://stackoverflow.com/questions/48078877/orion-cb-doesnt-handle-iot-agent-replies > +Question:+ > Orion CB doesn't handle IoT agent replies > +Description:+ > I'm developing a system in which I use Orion CB as main event bus making use also of the iotagent node lib in order to have an interface with third party APIs. > Now what happens is that I register a new device on the iotagent with only lazy attributes, one of which should be a json string. > Overriding the query handler and its subfunctions I tried both to stringify this json string and leaving it in json format and this is what i get: > 1) Stringify the json: > When I query Orion to retrieve the entity it replies that that entity does not exist with status code 404. Looking on the iotagent debug log I see that its response is exactly what I was expecting (with all attributes well formatted) and it ends with "statusCode":{"code": 200, "reasonPhrase": "OK"} so it seems that the iotagent is repling to Orion with status code 200 (success!). > 2) Leave the json as it is: > When I query Orion to retrieve the entity it replies with status code 200, all attributes are ok but the one with the json, that is empty. Again, looking at the iotagent debug log I see that the response is what I'd like to see quering to Orion and it ends with "statusCode":{"code": 200, "reasonPhrase": "OK"}. > What is happening here? What could be the problem in the first case? It seems that for some reason Orion doesn't like the iotagent response and it says that the entity doesn't exist. While in the second case i think the problem could be in the data structure that is not allowed (json as attribute value). > Am I missing something? I'd be glad if someone can help me with this truble, let me know if you require more informations. > Edit: > This is how I'm provisioning the device: > { > "devices": [ > { > "device_id": "taxi_list", > "entity_name": "taxi_list", > "entity_type": "taxilist", > "lazy": [ > { > "name": "taxiPosition", > "type": "StructuredValue" > }, > { > "name": "error", > "type": "string" > }, > { > "name": "status", > "type": "string" > }, > { > "name": "corsaRuntime", > "type": "string" > } > ] > } > ] > } > The attribute in which I need to have the json is "taxiPosition", so its type is "StructuredValue". Creating the response I just use JSON.parse() on the payload retrieved by the 'device' and assign this value to the attribute like: > responses.push({ > name: 'taxiPositions', > type: 'StructuredValue', > value: [{...}, {...}] > }); > Where the value is an array of objects with simple one-level key-value pairs formatted like this: > { "idTaxi": "100", "idStato": "1", "lat": "40.843227100000000", "lng": "14.228254600000000", "nome": "Salvatore", "cognome": "Scarinzi", "licenza": "2419", "cellulare": "+393396060655", "email": "salva.64 at libero.it", "targa": "CM698GN", "modelloAuto": "Focus SW", "marcaAuto": "Ford", "annoImmatricolazione": "2006", "passeggeri": "4", "dataCreazione": "2014-05-05", "rank": "4.2", "n_corse": "6", "os": "A", "dataOraInizioTurno": "05-01-2018 07:51", "dataOraFineTurno": "05-01-2018 11:50", "radio": "1", "pos": "0", "nome_radio": null, "iban": "" } > When I attempt to do it passing the value as a string the code is the same but the type for the attribute is "string" and the value is obtained by using JSON.stringify() on the previusly parsed json. > To query the entity from Orion I simply make a call to /v2/entities/taxi_list -- This message was sent by Atlassian JIRA (v6.4.1#64016)
You can get more information about our cookies and privacy policies clicking on the following links: Privacy policy Cookies policy