No love between node.js and otmonitor websockets

This Forum is about the Opentherm gateway (OTGW) from Schelte

Moderator: hvxl

Post Reply
sandervl
Starting Member
Starting Member
Posts: 2
Joined: Wed Aug 09, 2017 10:54 pm

No love between node.js and otmonitor websockets

Post by sandervl »

I'm building a solution where I am using Node-Red, a flow-based programming tool for wiring together hardware devices to talk to a number of sensors and to otmonitor. Node-Red offers a way to connect to websockets but for some reason it does not connect to otmonitor. Node-Red is based on node.js and uses the https://github.com/websockets/ws library and some tests in the console reveal that otmonitor responds with a 404 error. I ran more tests with http://www.websocket.org/echo.html and with the Simple Websocket Client Chrome extension and those all work fine. The Chrome Dev tools show a successful handshake. I can't seem to figure out why every library EXCEPT the self-proclaimed most stable and well-tested library is the only one that only doesn't work with otmonitor. In any case it halts further development of my project and I've spent over a week trying different setups. Anyone here have an similar experiences and/or solutions? I tried unraveling what kind of websocket library is in the source of otmonitor but it seems to be an add-on to the wibble http server that I can't debug.

See https://ibb.co/ezPNwa for the successful handshake in Chrome
labium
Advanced Member
Advanced Member
Posts: 512
Joined: Sat Feb 06, 2010 10:56 am
Location: netherlands

Re: No love between node.js and otmonitor websockets

Post by labium »

this is an interface for opentherm to Homey written in node https://github.com/nlrb/com.tclcode.otgw works great
sandervl
Starting Member
Starting Member
Posts: 2
Joined: Wed Aug 09, 2017 10:54 pm

Re: No love between node.js and otmonitor websockets

Post by sandervl »

I found out what the problem is, otmonitor requires the origin header to be set. Weirdly enough it doesn't matter what you set it to as long as it's not empty. This .js code works fine:

var socket = new ws(node.path, {
origin: "localhost"
});

And the result in the command line is as follows:

$ node ws.test.js

{"status": {"dhwmode": "1"}}
{"status": {"hotwater": "1"}}
{"status": {"flame": "1"}}
{"status": {"flame": "1"}}
{"status": {"boilertemp": "54.00"}}
{"status": {"boilerwatertemperature": "54.00"}}

So all is good, now I'm trying to get this feature added to Node-Red. Building my own node as we speak and see if I can get this option exposed in the core nodes to save everyone the trouble.
hvxl
Senior Member
Senior Member
Posts: 1965
Joined: Sat Jun 05, 2010 11:59 am
Contact:

Re: No love between node.js and otmonitor websockets

Post by hvxl »

The check for the origin header was part of the websocket code I copied from the Tclers Wiki. But you are right, RFC6455 does not require the header to be present. I will remove the check.
Schelte
Post Reply

Return to “Opentherm Gateway Forum”