Sample Apps for MQTT, Socket and REST protocols
| On root
level run npm install
|
-
cd HTTP-Request
-
npm install
-
Open
serverHTTPRequest.js
and edit it to look like belowconst server = Hapi.server({ host: 'http://localhost', port: 8000 });
-
save it and run
node serverHTTPRequest.js
-
Open the
clientHTTPRequest.js
and edit it to look like belowpostData('http://localhost:8000/hello', body)
-
Open the
index.html
in the browser from a local server (XAMPP, MAMPP, Express, etc) -
Click on the Send Request button
-
cd MQTT-Request
-
run
npm install
-
run
node mqttServer.js
-
Open the mqttClient.js` file and edit it to look like below
var client = mqtt.connect({ port: 3000, host: "localhost", "protocolId": "MQTT", keepalive: 10000 });
-
Save it and open the
index.html
in the browser from a local server (XAMPP, MAMPP, Express, etc) -
Click on the Send Request button
-
cd Socket-Request
-
run
npm install
-
run
node serverSocketConnect.js
-
Open
clientSocketConnect.js
and edit it to look like below
const socket = io('localhost:8080');
-
Open the
index.html
in the browser from a local server (XAMPP, MAMPP, Express, etc) -
Click on the Send Request button