eclipse-paho / eclipse-paho/paho.mqtt.javascript
Reconnection failed : trying to add reconnect Paho mqtt
- Dominant language
- JavaScript
- Stars
- 1.2k
- Forks
- 466
- PR merge metrics
- No merged PRs in 30d
Description
I'm trying to reconnect after lost connection using javascript (React native)
```
const client = new Paho.MQTT.Client(host, Number(port), clientID);
client.onMessageArrived = this.onMessageArrived;
client.onConnectionLost = this.onConnectionLost;
client.connect({
cleanSession : false,
onSuccess : this.onConnect,
userName: "user",
password: "pass",
onFailure : this.onConnectionLost,
reconnect : true, // Enable automatic reconnect
reconnectInterval: 10 // Reconnect attempt interval : 10 seconds
});
onConnect = () => {
const { client } = this.state;
console.log("Connected!!!!");
this.setState({isConnected: true, error: ''});
client.subscribe(topic, qos=1);
client.subscribe(topic1, qos=1);
client.subscribe(topic2, qos=1);
};
onConnectionLost(responseObject) {
if (responseObject.errorCode !== 0) {
console.log("onConnectionLost : "+responseObject.errorMessage);
this.setState({error: 'Lost Connection', isConnected: false});
}
}
```
> Error: Unknown property, reconnectInterval. Valid properties are: timeout userName password willMessage keepAliveInterval cleanSession useSSL invocationContext onSuccess onFailure hosts ports reconnect mqttVersion mqttVersionExplicit uris
Contributor guide
Research direction
Start by checking Paho MQTT JavaScript's documented connect options and compare them with the valid-property list in the reported error. Done means automatic reconnection is either confirmed with a reproducible test or the required library change is clearly scoped.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, react-native
- Domain
- networking
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 28/100