Uploaded image for project: 'Help-Desk'
  1. Help-Desk
  2. HELP-13270

[fiware-stackoverflow] Orion CB doesn't handle IoT agent replies

    Details

      Description

      Created question in FIWARE Q/A platform on 03-01-2018 at 14:01
      Please, ANSWER this question AT 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@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

        Activity

        Hide
        backlogmanager Backlog Manager added a comment -

        2018-01-12 19:48|CREATED monitor | # answers= 0, accepted answer= False

        Show
        backlogmanager Backlog Manager added a comment - 2018-01-12 19:48|CREATED monitor | # answers= 0, accepted answer= False
        Hide
        backlogmanager Backlog Manager added a comment -

        2018-02-06 15:05|UPDATED status: transition Answer| # answers= 1, accepted answer= False

        Show
        backlogmanager Backlog Manager added a comment - 2018-02-06 15:05|UPDATED status: transition Answer| # answers= 1, accepted answer= False
        Hide
        backlogmanager Backlog Manager added a comment -

        2018-02-06 18:05|UPDATED status: transition Answered| # answers= 1, accepted answer= False

        Show
        backlogmanager Backlog Manager added a comment - 2018-02-06 18:05|UPDATED status: transition Answered| # answers= 1, accepted answer= False
        Hide
        josegato Jose Gato Luis added a comment -

        answered but not response from the user if ok

        Show
        josegato Jose Gato Luis added a comment - answered but not response from the user if ok

          People

          • Assignee:
            josegato Jose Gato Luis
            Reporter:
            backlogmanager Backlog Manager
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: