Why Use Mqtt Node.js Library?
Solution 1:
The Paho JavaScript client is specifically targeted for use in client side (in the browser) and uses MQTT over Websockets to connect to MQTT brokers that support this transport layer. It is the reference implementation for MQTT over Websockets.
Assuming you mean the MQTT.js package when talking about the "Node.JS one" this is a pure javascript implementation of the a MQTT client that can use either native MQTT or MQTT over Websockets when used with Node.JS to build client applications. It can also be used with a tool such as Browserify and Webpack then it can be packaged to be used in the web browser to connect to a MQTT broker using MQTT over Websockets
When you choose to use each depends on what you are trying to do, if you are purely writing a web client solution then the Paho library will meet your needs. If you are writing a Node.JS application then obviously then the MQTT.js is the correct choice. If you are writing both then there may be some merit in using the MQTT.js library in the both places to ensure consistency.
Solution 2:
when you use mqtt broker, you should install npm package of mqtt, that package you can get from node.js.
using command : npm install mqtt
Post a Comment for "Why Use Mqtt Node.js Library?"