-
Notifications
You must be signed in to change notification settings - Fork 25
Open
Description
I am new to homA and just installed this and node.js on a RPi running jessie.
After npm install and running demo I got an error message:
self.mqttClient = mqtt.createClient(port || params.brokerPort, host || params.brokerHost, extraParameters);
TypeError: mqtt.createClient is not a function
Google helped:
createClient() has been deprecated by mqtt module, use connect() instead.
Installed versions:
> npm version
{ npm: '3.10.10',
ares: '1.10.1-DEV',
http_parser: '2.7.0',
icu: '58.2',
modules: '48',
node: '6.10.0',
openssl: '1.0.2k',
uv: '1.9.1',
v8: '5.1.281.93',
zlib: '1.2.8' }
> node_modules/mqtt/mqtt.js version
MQTT.js version: 2.4.0
So, I patched homa.js like this:
--- ./misc/libraries/node/homa/homa.js 2017-02-22 19:46:33.878485086 +0100
+++ ./components/demo/node_modules/homa/homa.js 2017-02-22 21:55:41.019057301 +0100
@@ -2,6 +2,7 @@
// 2013 Alexander Rust <mail@alr.st>
// Use it as you like if you find id usefull
+const url = require('url');
var util = require('util');
var events = require('events');
var mqtt = require('mqtt');
@@ -107,7 +108,10 @@
self.scheduledPublishes = [];
this.connect = function(host, port, extraParameters) {
- self.mqttClient = mqtt.createClient(port || params.brokerPort, host || params.brokerHost, extraParameters);
+ const brokerUrl = url.parse(host || params.brokerHost);
+ brokerUrl.port = port || params.brokerPort;
+ self.mqttClient = mqtt.connect(brokerUrl);
log.info("MQTT", "Connecting to %s:%s", host || params.brokerHost, port || params.brokerPort);
self.mqttClient.on('connect', function() {
I do not know what extraParameters is for and how it should be used in url object context. Right now it works so far ...
Holger
Metadata
Metadata
Assignees
Labels
No labels