[ https://jira.fiware.org/browse/HELP-21086?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Fernando Lopez deleted HELP-21086: ---------------------------------- > [fiware-stackoverflow] Fail subscription to Orion change contest from Node Server > --------------------------------------------------------------------------------- > > Key: HELP-21086 > URL: https://jira.fiware.org/browse/HELP-21086 > Project: Help-Desk > Issue Type: Monitor > Reporter: Backlog Manager > Labels: fiware, fiware-orion, node.js, request, server > > Created question in FIWARE Q/A platform on 25-03-2023 at 16:03 > {color: red}Please, ANSWER this question AT{color} https://stackoverflow.com/questions/75843013/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? -- 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