Mqtt.js: How use MQTT.js with weapp

Created on 8 Jan 2019  路  2Comments  路  Source: mqttjs/MQTT.js

Sorry !
I copied dist/mqtt.js to my weapp's project then required it. like that

var mqtt = require('../../MQTT/mqtt.js')
const client = mqtt.connect('wss://****:8884')

but it can not work . Console show the error:

sdk uncaught third Error
WS is not a constructor
TypeError: WS is not a constructor

Would you please provide a simple working example of weapp? thinks

Most helpful comment

@guakeliao

var mqtt = require('../../MQTT/mqtt.js')
const client = mqtt.connect('wss://****:8884')

use wxs or wx in weapp

All 2 comments

Hi, I would suggest looking at some of the existing issues related to weapp to see if there are any examples there.

@guakeliao

var mqtt = require('../../MQTT/mqtt.js')
const client = mqtt.connect('wss://****:8884')

use wxs or wx in weapp

Was this page helpful?
0 / 5 - 0 ratings