Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

op-en-app-server

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

op-en-app-server

Socket.IO server that allows access to an MQTT broker.

  • 0.1.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

Open Energy App Server

This is part of the Open Energy Project, a research project aiming to make it easier and faster to prototype smart energy services.

Description

This Node.js server is a bridge from MQTT to websockets using socket.io. The server is connected to an MQTT broker and relays all messages that the connected client requests.

If messages are published to the server, they are forwarded to the MQTT broker under the 'appserver/session/[id]' topic.

Installation

npm install -g op-en-app-server

Configuration

All configuration of the server is done via environment variables, as compliant with a 12 factor app.

See index.js for default config.

Starting the server

When installed as a global package, the server can simply be started by running:

op-en-app-server

Client example

Client example using socket.io client in a web app:

var socket = io.connect('http://localhost:5000');
socket.on('connect', function () {
  socket.on('mqtt', function (msg) {
    console.log(msg.topic+' '+msg.payload);
  });
  socket.emit('subscribe',{topic:'/some/sensor/data'});
});

When new clients connect to the server it publishes a "Connected" message on the MQTT path appserver/session/N/

When the clients publish by:

socket.emit('publish',{topic:'/path',payload:'test'});

The message ("test") will be sent to the path AppServer/session/{N}/{path}

Where N is the session id and path the topic in the emit command.

Testing

For development, there is a suite of Mocha unit tests, run them with

npm test

The test suite can also be run to ensure that the server is running and responding correctly in a different environment (like. remote server, docker, virtual machine etc.). In that case, the environment variable HOST specifies what server to test.

So if you want to test a server on the url op-en.se on port 5000 for example, you would run:

env HOST=http://op-en.se:5000 npm test

Keywords

FAQs

Package last updated on 16 Nov 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc