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

FIWARE.Question.Tech.Fail subscription to Orion change contest from Node Server.

    Details

      Description

      Created question in FIWARE Q/A platform on 26-03-2023 at 17:03
      Please, ANSWER this question AT https://stackoverflow.com/questions/75849244/fail-subscription-to-orion-change-contest-from-node-server

      Question:
      Fail subscription to Orion change contest from Node Server

      Description:
      I am developing a simple project in which I made a list of entities that I put on Orion-LD. Now I would like to make a server that allows to receive notifications whenever the state of an entity attribute changes. i chose to use Node.JS Express for ease but it is not mandatory.
      I am leaving here the simple code used to implement my server.
      const express = require('express');
      const request = require('request');

      const app = express();
      const PORT = 3000;

      //Subscription on batteryLevel changes of device 9845A
      app.get('/subscribe', (req, res) => {
      const data = {
      "description": "Subscription",
      "subject": {
      "entities": [

      { "id": "urn:ngsi-ld:Device:9845A", "type": "Device" }

      ],
      "condition":

      { "attrs": ["batteryLevel"] }

      },
      "notification": {
      "http": {
      "url": `http://localhost:$

      {PORT}/notification`
      },
      "attrsFormat" : "keyValues"
      }
      };

      const options = {
      headers: { 'Content-Type': 'application/json', },
      json: data
      };

      request.post('http://localhost:1026/v2/subscriptions', options, (error, response, request) => { console.log(response.body); res.end("Succesfully subscribed!"); });
      });

      // Listen on notification
      app.post('/notification', (req, res) => {
      console.log('Notification received:', req.body);
      res.sendStatus(200);
      });

      app.listen(PORT, () => {
      console.log(`Example app listening on port ${PORT}

      `)
      });

      The problem is that if I subscribe to an existing entity properly, it reports a "status": "failed" in the subscription and therefore I cannot receive notifications about the status. Reading the Orion LD logs, it seems that it can't communicate with my server at port 3000, but I can't figure out why. Can anyone help me with this?

        Activity

        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Open Open In Progress In Progress
        2d 1 Backlog Manager 29/Mar/23 7:32 AM
        In Progress In Progress Answered Answered
        23h 59m 1 Backlog Manager 30/Mar/23 7:32 AM
        Answered Answered Closed Closed
        96d 23h 59m 1 Backlog Manager 05/Jul/23 7:31 AM
        backlogmanager Backlog Manager made changes -
        Summary [fiware-stackoverflow] Fail subscription to Orion change contest from Node Server FIWARE.Question.Tech.Fail subscription to Orion change contest from Node Server.
        HD-Enabler Unknown [ 10910 ]
        HD-Chapter Unknown [ 10845 ]
        HD-Node Unknown [ 10852 ]
        Hide
        backlogmanager Backlog Manager added a comment -

        2023-07-05 05:31|UPDATED status: transition Finish| # answers= 1, accepted answer= True

        Show
        backlogmanager Backlog Manager added a comment - 2023-07-05 05:31|UPDATED status: transition Finish| # answers= 1, accepted answer= True
        backlogmanager Backlog Manager made changes -
        Resolution Done [ 10000 ]
        Status Answered [ 10104 ] Closed [ 6 ]
        Hide
        backlogmanager Backlog Manager added a comment -

        2023-03-30 05:31|UPDATED status: transition Answered| # answers= 1, accepted answer= False

        Show
        backlogmanager Backlog Manager added a comment - 2023-03-30 05:31|UPDATED status: transition Answered| # answers= 1, accepted answer= False
        backlogmanager Backlog Manager made changes -
        Status In Progress [ 3 ] Answered [ 10104 ]
        Hide
        backlogmanager Backlog Manager added a comment -

        2023-03-29 05:32|UPDATED status: transition Answer| # answers= 1, accepted answer= False

        Show
        backlogmanager Backlog Manager added a comment - 2023-03-29 05:32|UPDATED status: transition Answer| # answers= 1, accepted answer= False
        backlogmanager Backlog Manager made changes -
        Status Open [ 1 ] In Progress [ 3 ]
        backlogmanager Backlog Manager made changes -
        HD-Enabler Unknown [ 10910 ]
        HD-Chapter Unknown [ 10845 ]
        HD-Node Unknown [ 10852 ]
        backlogmanager Backlog Manager made changes -
        Field Original Value New Value
        Component/s FIWARE-TECH-HELP [ 10278 ]
        Hide
        backlogmanager Backlog Manager added a comment -

        2023-03-27 05:31|CREATED monitor | # answers= 0, accepted answer= False

        Show
        backlogmanager Backlog Manager added a comment - 2023-03-27 05:31|CREATED monitor | # answers= 0, accepted answer= False
        backlogmanager Backlog Manager created issue -

          People

          • Assignee:
            Unassigned
            Reporter:
            backlogmanager Backlog Manager
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: