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

        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
        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
        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
        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

          People

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

            Dates

            • Created:
              Updated:
              Resolved: