Comments (9)
Hi @tringler I think you use bad the mqtt method
check this
https://github.com/mqttjs/MQTT.js/blob/master/examples/client/simple-both.js
whit this I can run ./runner.sh
from mqtt-panel.
Can you try to change
<script type="text/javascript" src="http://localhost:3000/socket.io/socket.io.js"></script>
to something like
<script type="text/javascript" src="js/socket.io.min.js"></script>
from mqtt-panel.
Changed to <script type="text/javascript" src="js/socket.io.min.js"></script>
in index.html, but running into the same behaviour. How can I test if the module socket.io
is accessible by your script?
from mqtt-panel.
It has been solved by npm install socket.io --save
from mqtt-panel.
It stops now with:
var mqttclient = mqtt.createClient(mqttport, mqttbroker);
^
TypeError: mqtt.createClient is not a function
at Object.<anonymous> (/etc/mqtt-panel/server.js:15:23)
at Module._compile (module.js:571:32)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.runMain (module.js:605:10)
at run (bootstrap_node.js:423:7)
at startup (bootstrap_node.js:147:9)
at bootstrap_node.js:538:3
from mqtt-panel.
I changed var mqttclient = mqtt.createClient(mqttport, mqttbroker);
to var mqttclient = mqtt.connect(mqttport, mqttbroker);
Take a look at: mqttjs/MQTT.js#247
Now it stops with:
TypeError: Parameter "url" must be a string, not number
at Url.parse (url.js:81:11)
at Object.urlParse [as parse] (url.js:75:5)
at Object.connect (/etc/mqtt-panel/node_modules/mqtt/lib/connect/index.js:52:22)
at Object.<anonymous> (/etc/mqtt-panel/server.js:15:23)
at Module._compile (module.js:571:32)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.runMain (module.js:605:10)
from mqtt-panel.
Changed var io = socket.listen(3000);
to var io = socket.listen('http://localhost:3000');
Now it stops with:
/etc/mqtt-panel/node_modules/engine.io/lib/server.js:424
var listeners = server.listeners('request').slice(0);
^
TypeError: server.listeners is not a function
at Server.attach (/etc/mqtt-panel/node_modules/engine.io/lib/server.js:424:26)
at Function.attach (/etc/mqtt-panel/node_modules/engine.io/lib/engine.io.js:124:10)
at Server.listen.Server.attach (/etc/mqtt-panel/node_modules/socket.io/lib/index.js:240:21)
at new Server (/etc/mqtt-panel/node_modules/socket.io/lib/index.js:52:17)
at Function.Server [as listen] (/etc/mqtt-panel/node_modules/socket.io/lib/index.js:40:41)
at Object.<anonymous> (/etc/mqtt-panel/server.js:14:17)
at Module._compile (module.js:571:32)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
from mqtt-panel.
Why is this closed?
Current code as of today does not run, I have the same errors @tringler has.
from mqtt-panel.
The current change makes it work for me:
diff --git a/server.js b/server.js
index 4af2095..96838e7 100644
--- a/server.js
+++ b/server.js
@@ -9,10 +9,10 @@ var socket = require('socket.io');
//var firmata = require('firmata');
var mqttbroker = 'localhost';
-var mqttport = 1883;
+var mqttport = '1883';
var io = socket.listen(3000);
-var mqttclient = mqtt.createClient(mqttport, mqttbroker);
+var mqttclient = mqtt.connect('tcp://' + mqttbroker + ':' + mqttport);
// Subscribe to topic
io.sockets.on('connection', function (socket) {
from mqtt-panel.
Related Issues (8)
- MQTT Websockets HOT 3
- [email protected] This version doesn't seem to work properly
- I get an error when I start the server.js HOT 1
- Replace the jqplot with Chart.js. HOT 1
- 'Connection reset by peer' when sending a message HOT 2
- Migrate LGTM.com installation from OAuth to GitHub App
- No colors on the page HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mqtt-panel.