A developer lost in the mountains

Orion Context Broker: delete a subscription without having the ID

I was testing the subscription/notification feature of Orion Context Broker (  and I made a number of subscriptions without taking note of the ID of the new subscription returned by the system.

Soon I went in a situation where Orion was firing a lot of notifications  to the Cygnus connector that I had configured.

I wanted to delete most of the subscriptions, but the REST call available, i.e. unsubscribeContext, requires that you know the id of the subscription. What to do then?

Official documentation suggests, as ultimate remedy, to delete the entire database: (

But I was reluctant to follow this way and then I looked for a mongodb admnistration and found this umongo:

The installation is trivial: just download the zip file, unzip and launch

I loaded the default instance of mongodb in my linux box and started to look for an id under orion databases; the subscriptions are in the csubs collection:

Then I created a simple REST call in SoapUI to unsubscribe the subscription with that ID:

Freeboard and Orion Context Broker - a workaround for the CORS issue

Orion Context Broker is an open source component belonging to the wide archipelago of FIWARE components available on this site.

In particular, if you are developing a Data/Context scenario, the Orion Context Broker plays the role of a component in the architecture able to mediate between consumer producers (e.g. sensors) and the context consumer applications (e.g. an smartphone applications taking advantage of the context information provided by the sensors). It runs as a deamon process providing NGSI9 and NGSI10 interfaces. Full documentation here.

When I started to work with Orion Context Broker for my SAT project, I looked around to find a quick & stylish solution to display data stored in the DB used by Orion CB (btw mongoDB); soon I found Freeboard, a nice open source dashboard for the Internet of Things and a "ready to work" plugin for Freeboard that is able to connect it to an Orion instance: Freeboard-Orion-Plugin.

All right? All OK? No, unfortunately the plugin did not work in all my attempts . The fact is that, behind the scene, the freeboard plugin makes a cross-domain Ajax call to my Orion instance and this is inhibited by design due to browser-enforced, same-origin security policies for JavaScript.

What to do then ? Recently W3C came out with the Cross Origin Resource Sharing (CORS) specification, a mechanism that works by adding HTTP headers to cross-domain HTTP requests and responses. The headers indicate the origin of the request and the server has to inform via headers in the response whether it will serve resources to this origin.  This exchange of headers is what makes CORS a secure mechanism totaly transparent to the user since the headers are built by the browser and the server.

So, why it did not worked in my case?

Just because Orion context Broker server does not support CORS at the moment:

there is more than a solution to get rid of the problem. You may create for instance a proxy in PHP:

My Solution:

I followed a different way; I installed Apache httpd on the same machine of the Orion instance and I used it as a proxy.

To do so just follow the steps below:

1) Edit httpd.conf file in /etc/httpd/conf and instruct Apache to load proxy module add the following lines at the end:

LoadModule  proxy_module         modules/
LoadModule  proxy_http_module    modules/
LoadModule  headers_module       modules/
LoadModule  deflate_module       modules/

2) Add proxy permissions as your choice:

<Proxy *>
   Order deny,allow
Allow from all

3) Add some rules to instruct Apache to intercept NGSI calls to Orion:

ProxyPass /v1/queryContext
ProxyPassReverse /v1/querycontext
ProxyPass /v1/registerContext
ProxyPassReverse /v1/registerContext
ProxyPass /v1/updateContext
ProxyPassReverse /v1/updateContext

4) Save conf file and restart your httpd server