Skip to content

Unable to connect - MQTT protocol URL (plugin@taoqf/react-native-mqtt) #8

Description

@shalini-whiz

Here, I have integrated this plugin in my react native project and trying to connect URL with protocol mqtt. Referred doc
https://github.com/taoqf/MQTT.js/blob/react-native/README.md
Am unable to detect either connected or not. Below is my snippet
let mUrl = "mqtt://xxxx.xxxx.in";
let mOptions = {
username: server_user, password: server_pass,
protocol: 'mqtt',
clientId: 'mqttjs_' + Math.random().toString(16).substr(2, 8),
rejectUnauthorized: false,
protocolId: 'mqtt',
defaultProtocol:"mqtt",
protocolVersion: 4,
clean:false
}
var client = mqtt.connect(mUrl,mOptions);
client.on('connect', function () {
console.log("connected");
})
})
client.on('error', function ( err) {
console.log("client err : " + err)
})

Can anyone help ?

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions