taoqf / mqtt.js Goto Github PK
View Code? Open in Web Editor NEWThis project forked from mqttjs/mqtt.js
The MQTT client for Node.js and the browser
License: Other
This project forked from mqttjs/mqtt.js
The MQTT client for Node.js and the browser
License: Other
Is it possible for you to add more info about the linking process on the readme as well as with kind of data the message type supports ?? Thank you very much
Whenever tires to connect to a server by mqtt protocol, close event is emitted before getting connected. But works fine with ws/wss protocol.
const mqtt = require('@taoqf/react-native-mqtt')
const client = mqtt.connect('mqtt://XXX.XXX.XXX.XXX:1883);
Example: const client = mqtt.connect('mqtt://test.mosquitto.org:1883');
Hi @taoqf , when i try connecting to any any stream with any protocol. The connection close callback gets called regularly. Even the below snippet doesn't work. Is it a bug ?.
var mqtt = require('@taoqf/react-native-mqtt')
var client = mqtt.connect('mqtt://test.mosquitto.org')
client.addListener('connect', () => {
console.log('connected');
});
client.on('connect', function () {
client.subscribe('presence', function (err) {
if (!err) {
client.publish('presence', 'Hello mqtt')
}
})
})
last version is 4.2.8
Hey! I'm trying to connect and get the data from topic sent by sensor. Unfortunately the connection not working.
Any help is appreciated.
import init from 'react_native_mqtt'
import AsyncStorage from '@react-native-async-storage/async-storage'
init({
size: 10000,
storageBackend: AsyncStorage,
defaultExpires: 1000 * 3600 * 24,
enableCache: true,
reconnect: true,
sync : {
}
});
const host = '52.11.11.11'
const port = '8883'
const connectUrl = `mqtt://${host}:${port}`
clientID = "clientID-" + parseInt(Math.random() * 100);
export default class TestScreen extends Component {
constructor(){
super();
this.onConnectionLost = this.onConnectionLost.bind(this)
this.onConnect = this.onConnect.bind(this)
const client = new Paho.MQTT.Client(host, Number(port), clientID);
client.onConnectionLost = this.onConnectionLost;
client.connect({
onSuccess: this.onConnect,
useSSL: true,
userName: 'admin',
password: 'admin',
onFailure: (e) => {console.log("here is the error" , e); }
});
this.state = {
message: [''],
client,
messageToSend:'',
isConnected: false,
};
}
onConnect = () => {
// const { client } = this.state;
console.log("Connected!!!!");
//client.subscribe('hello/world');
this.setState({isConnected: true, error: ''})
};
my enviorment: [email protected]
the dev no problem, but pakageing apk INVALID_STATE_ERR is causing the device to CRASH;
I find start mqtt. the app crash.
I try no run mqtt , the app no problem.
I don't find other problem.
You can hlep me.
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.