No love between node.js and otmonitor websockets

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

Moderator: hvxl

No love between node.js and otmonitor websockets

Postby sandervl » Wed Aug 09, 2017 10:40 pm

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
sandervl
Starting Member
Starting Member
 
Posts: 2
Joined: August 2017

Re: No love between node.js and otmonitor websockets

Postby labium » Thu Aug 10, 2017 12:25 pm

this is an interface for opentherm to Homey written in node https://github.com/nlrb/com.tclcode.otgw works great
labium
Member
Member
 
Posts: 470
Joined: February 2010
Location: netherlands

Re: No love between node.js and otmonitor websockets

Postby sandervl » Thu Aug 10, 2017 9:36 pm

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.
sandervl
Starting Member
Starting Member
 
Posts: 2
Joined: August 2017

Re: No love between node.js and otmonitor websockets

Postby hvxl » Sat Sep 23, 2017 11:12 am

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
hvxl
Senior Member
Senior Member
 
Posts: 1026
Joined: June 2010


Return to Opentherm Gateway Forum

Who is online

Users browsing this forum: No registered users and 1 guest