Comments (8)
If you are using the autoreconnect functionality it will run till it reconnects unless you stop it.
I cant comment on why this affects your ui.
from mqtt5_client.
shall make connect function be a async function?
Currently it happens when network are not stable, don't why
from mqtt5_client.
If your network is so unstable you can't connect then you ate going to have trouble with MQTT. It makes no difference to the client whether its sync or async, if you can't connect you are stuck. You need to put the client as a whole on its own isolate maybe.
from mqtt5_client.
Is there any reconnect timeout try times or interval time params to set?
Currently it will reonnect quickly when network unstable (note: not offline, if offline I can detect, but network not stable or slow I can not really detect this)
from mqtt5_client.
You can change the amount of retries, see the API spec. You could monitor the connect callback, if this is not called after a time interval you could disconnect, back off and try connecting later.
from mqtt5_client.
@shamblett thanks.
I have set maxReconnectTimes to 3:
_client =
MqttServerClient.withPort(host, cid, 1883, maxConnectionAttempts: 3);
// MqttServerClient.withPort("test.mosquitto.org", cid, 1883,
// maxConnectionAttempts: 3);
kLog(
'!!!! ------------> [conn] connect with $host, $port, $username, $password, ${_clientId} $_client');
// _client!.logging(on: true);
_client!.logging(on: false);
_client!.onConnected = onConnected;
_client!.onDisconnected = onDisconnected;
_client!.onUnsubscribed = onUnsubscribed;
_client!.onSubscribed = onSubscribed;
_client!.onSubscribeFail = onSubscribeFail;
_client!.onAutoReconnect = onAutoReconnect;
_client!.pongCallback = pong;
_client!.keepAlivePeriod = 60 * 3;
_client!.autoReconnect = true;
_client!.useWebSocket = useWebsocket;
final connMessage = MqttConnectMessage()
.authenticateAs(username, password)
.withSessionExpiryInterval(3600 * 24 * 14) // last for 7 days
.keepAliveFor(120)
// .withWillTopic('lastwills')
// .withWillMessage('Will message')
.withClientIdentifier(cid);
// .withProtocolName("MQTT")
// .withProtocolVersion(4)
// .withSessionExpiryInterval(interval)
// .withWillQos(MqttQos.atLeastOnce);
_client!.connectionMessage = connMessage;
But, when the network are poor, the connect actually connects, but it still will reconnect, ( i have receive the connected welcome message).
Can u give me some suggestions, why I set max tries and reconnect, it will reconnect repeatly very quickly?
from mqtt5_client.
Your using autoreconnect = true so post initial connection.if the connection is lost the client will try and reconnect automatically forever.
If you turn this off you can control when you reconnect after a disconnect using the onConnected/onDisconnected callbaclks.
from mqtt5_client.
Your using autoreconnect = true so post initial connection.if the connection is lost the client will try and reconnect automatically forever.
If you turn this off you can control when you reconnect after a disconnect using the onConnected/onDisconnected callbaclks.
thanks, how to turn it off? You mean do not auto reconnect? But I need auto reconnect, in case people offline it will auto reconnect,
but the problem is the reconnect interval are too quicky
from mqtt5_client.
Related Issues (20)
- Cannot add new events after calling close HOT 7
- Getting message twice while listening to MqttPublishMessage stream. HOT 2
- Can not receiving client offline messages HOT 1
- OnDisconnect not triggered once connection is established HOT 1
- MqttSubscriptionTopic().matches function throws exception upon different lengths of topics HOT 2
- Fix linter warnings introduced by linter 3.0.0 HOT 1
- Hello, this client everything works fine except it will drop connect by server HOT 4
- Problem to conect Flutterflow an HOT 1
- How to control autoConnect time? HOT 11
- Replace `dart:html` to `universal_html` for better universal support HOT 1
- Null check operator used on a null value HOT 2
- How to recall a time-out message? HOT 4
- MQTT Socketexception when going offline HOT 13
- MqttBrowserClient set certificate on wss connection HOT 2
- Request/Response full support / Update README HOT 6
- Error on unsubscribeMqttSubscription userProperties is null HOT 3
- how to use MqttBrowserClient HOT 2
- Subject: RangeError in mqtt5_client library - Client-side fix or library update needed? HOT 5
- Would like a way to capture low level socket errors 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 mqtt5_client.