Comments (8)
Hi There,
I am also getting same issue in app.
When i connect app with sensors and publish data, after 2-3 mins app suddenly drops connection to MQTT broker with following error.
"Error while connecting to MQTT serverConnection lost (32109) - java.net.SocketException: Connection timed out"
Any help would be appreciated.
Thanks
from cordova-plugin-mqtt.
I can help you if you need it...
from cordova-plugin-mqtt.
@adrianmihaila Yes, I'm still facing this issue. Please let me know what is the fix.
from cordova-plugin-mqtt.
@vamshik113, I had the same problem, but I found a workaround.
class MqttClient {
connect(successCallback) {
let clientId = 'm-' + device.uuid;
cordova.plugins.CordovaMqTTPlugin.connect({
url: MQTT_BROKER_URL,
port: MQTT_BROKER_PORT,
clientId: clientId,
keepAlive: 0,
reconnectPeriod: 1000,
clean: false,
success: successCallback,
error: (e) => {
console.error('Mqtt connection error: ' + JSON.stringify(e));
},
onConnectionLost: () => {
this.connect(successCallback); // Here is the magic. On connection lost, you will try to reconnect.
}
});
}
....
}
document.addEventListener('deviceready', () => {
let mqttClient = new MqttClient();
mqttClient.connect(() => {
// Subscribe method is another wrapper for cordova.plugins.CordovaMqTTPlugin.subscribe()
mqttClient.subscribe(TOPIC, QOS_LEVEL);
});
});
I made a suite of manual tests and all of them have passed.
Adi
from cordova-plugin-mqtt.
Hi
I got the same issue when two tablets with the same application connect to MQTT Server (Mosquitto on raspberry pi)
I observe that the application lost connection with server (Error while connecting to MQTT serverConnection lost (32109) - java.net.SocketException: Software caused connection abort) when on an other tablet the application connect.
They should have different Client ID
cordova.plugins.CordovaMqTTPlugin.connect({ url:"tcp://" + config.gateway, port:config.port, clientId:"TABLETTE_" + macAdd, connectionTimeout:3000, willTopicConfig:{qos:0, //default is 0 retain:true, //default is true topic: lastWillTopic, payload: lastWillPayload }, username:config.MQTT_log, password:config.MQTT_PW, keepAlive:10, isBinaryPayload: false });
but I suspect an issue about that and the ClientID is the same for all application (whatever you set as clientId)
any idea ?
from cordova-plugin-mqtt.
Hi,
According to MQTT spec, we cannot reuse same Client ID which is used previously. The broker shall deny connection or close previous connection. The library generates a random Client ID if it is unset or left blank.
from cordova-plugin-mqtt.
Actually if clientId is not set broker receive id null
It seems the library doesn't generate random clientId
from cordova-plugin-mqtt.
A newer version is being worked on here https://github.com/ameykshirsagar/cordova-plugin-mqtt . You can keep a tab on developments
from cordova-plugin-mqtt.
Related Issues (20)
- clean session flag support? HOT 1
- Subscribe to multiple topics. HOT 1
- Any news about SSL support mqtts? HOT 4
- Stop Listen (Un-Listen) to a topic without disconnect
- I need help, I don't know how to make it work HOT 5
- How to subscribe multiple topics ? HOT 4
- Raspberry Pi Broker
- I have a probelm MQTT Plugin is not working HOT 1
- Major updates Feb 2019 HOT 2
- Background Instance
- It star give error on visual studio
- Intent Service
- Publish function sometimes retain false, sometimes true HOT 2
- Can't open mqtt reconnect function
- 无法上传数据流报文 Unable to upload data stream message
- Ionic 4- Use Cordova-plugin-mqtt HOT 1
- SSL/TLS
- paho not defined HOT 2
- Client ID register as "null" by broker HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cordova-plugin-mqtt.