I have a Raspberry Pi with a ConBee 2 (ZigBee) interface connected. The ConBee provides a websocket I can connect to to get push notifications on sensor changes. And I want to forward those notifications using a HTTP method URL.

The current status is that the ConBee (Phoscon) is operational, and I receive push notifications from the ConBee if connecting using e.g. the SocketWrench application. I want to format the payload (and some of the meta data) from the websocket messages as a JSON object and send it as a HTTP method request (POST, I think).

Immediately I'm thinking of running a small C (or Python) application on the Raspberry Pi when it starts up. But is there a better way of doing this?


You are using term websocket (instead of "serial port") and do not specify how do you plan to forward(expose) data via HTTP. Most likely you plan to make http call to "third" device from RPI but probably you also want to expose devices via web interface which is running on RPI device. So your question can look a bit confusing. Probably that is the reason for an downvote.

I would suggest you to: 1) try RPI SD-Card image provided by phoscon. this way you will get your devices operational. This will also allow you to sniff on serial console to reverse engineer protocol used for data transfer. 2) if you really want to go DIY way then I suggest you to write some prototype with node.js - you can implement both options of forwarding (web client vs web server). I have node.js server running one of my RPI devices. uptime is 40 days and footprint of node process is just 100Mb. So it could be ok to use it not only for a prototyping but for "production" version as well. 3) then if you really would like to reduce footprint of your application then you could redo it in C, Go or Rust - I suggest you to give Go / Rust a go.

PS: I'm not javascript fun but I like the speed you can achieve while prototyping things.

UPDATE: So you already have software which reads data from serial port and converts it into message stream to all connected web clients.

Then information about RPI and ZigBee is irrelevant to the real question which should be "How do I consume websocket messages from one server and re-transmit data to another server via plain HTTP requests"

most likely next snippet will work for you:

#!/usr/bin/env node
var WebSocketClient = require('websocket').client;

var request = require('request');

var client = new WebSocketClient();

client.on('connectFailed', function(error) {
    console.log('Connect Error: ' + error.toString());

client.on('connect', function(connection) {
    connection.on('error', function(error) {
        console.log("Connection Error: " + error.toString());
    connection.on('close', function() {
        console.log('echo-protocol Connection Closed');
    connection.on('message', function(message) {
//forward data to the server2
       console.log("Received: '" + message.utf8Data + "'");
    request.post('http://server2/api-end-point',  { json: message },
        function (error, response, body) {
            if (!error && response.statusCode == 200) {


client.connect('ws://localhost:80/', 'uri-to-ws-endpoint');
  • Ah, I see.. I've updated the question with more information. So far I believe your suggestion no 3 (or perhaps 2) is the most relevant for me. – Oystein Nov 18 '19 at 16:35
  • Excellent, thanks alot. – Oystein Nov 19 '19 at 12:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.