Dear sir.
I'm trying to use mqtt over web socket, as described
https://github.com/mcollina/mosca/wiki/MQTT-over-Websockets
The client is running on Chrome.
Using the embedded MOSCA, it worked well.
But using the MQTT.js Browserify Bundle, it did not work.
My server side initialization is as follow:
//=============================================
// Mosca & Express initialization
var mosca = require("mosca");
var broker = new mosca.Server({});
var express = require("express");
var http = require("http");
var app = express()
var srv = http.createServer(app)
broker.attachHttpServer(srv);
// mqtt.js from node_modules/mosca/public was copied to the public folder
// thus the web root is the default public
app.use(express.static('public'));
app.listen(3000, () => console.log('WebApp listening on port 3000!'));
//=====================================
The express worked, it can serve the static HTML as well as the API.
However the MQTT client was failed with the following error:
WebSocket connection to 'ws://192.168.100.5:3000/' failed: Error during WebSocket handshake: Unexpected response code: 200
Please help. Thank you in advance.
Dear sir.
I'm trying to use mqtt over web socket, as described
https://github.com/mcollina/mosca/wiki/MQTT-over-Websockets
The client is running on Chrome.
Using the embedded MOSCA, it worked well.
But using the MQTT.js Browserify Bundle, it did not work.
My server side initialization is as follow:
//=============================================
// Mosca & Express initialization
var mosca = require("mosca");
var broker = new mosca.Server({});
var express = require("express");
var http = require("http");
var app = express()
var srv = http.createServer(app)
broker.attachHttpServer(srv);
// mqtt.js from node_modules/mosca/public was copied to the public folder
// thus the web root is the default public
app.use(express.static('public'));
app.listen(3000, () => console.log('WebApp listening on port 3000!'));
//=====================================
The express worked, it can serve the static HTML as well as the API.
However the MQTT client was failed with the following error:
WebSocket connection to 'ws://192.168.100.5:3000/' failed: Error during WebSocket handshake: Unexpected response code: 200
Please help. Thank you in advance.