Comments (22)
and this is heppend only on web environment in release mode in debug mode it's working fine.
now i don't have a any why how to resolve this issue.if you have any suggestion kindly share with us.
from mqtt_client.
OK, I'll need a client log to see whats happening here although this particular problem hasn't been reported before.
from mqtt_client.
Hello, @shamblett
please look client logs:
from mqtt_client.
The failure is in the connectAuto method so you must have lost your connection and triggered auto reconnect. It should stay in auto reconnect until it connects, does it eventually connect if you leave it long enough? I'll check the code to make sure we are recycling the socket.
from mqtt_client.
@shamblett For more than 30 minutes we do nothing on the web. Then we receive WebSocket error.
from mqtt_client.
Yes becsuse the network has disconnected you and cos u have autoreconnect set the client tries to reconnect, this is where the error appears.
If you do nothing and let the client just run dors it eventually re connect(assuming your network comes back of course) ?
Its also possible your broker has gone down but this is rarer.
from mqtt_client.
No, I didn't turn off the network.
the network is continuously on my pc.
from mqtt_client.
Ok, in that case when the autoreconnect sequence starts can you still ping your broker?
from mqtt_client.
no, not.
@shamblett please see attached photo
from mqtt_client.
No sorry I didnt mean from the client, the client is not connected so it will not send keep alive pings I meant the standar networking ping command at the cli or any other way u may want to verify ur broker is still reachable.
from mqtt_client.
Client is already reachable. how we tell. when i do browser refresh button in flutter hole application reinitialised and at that time new mqtt instance is created and that is working fine.
So broker is all time reachable and it's aws iot broker.
if i checked on mqttbox i able to connect with wss protocol.
from mqtt_client.
OK thanks for checking, what we need to know now is why auto reconnect is being triggered in the first place, i.e. why we have(or think we have) lost connection to the broker in the first place.
I need the client log from just above where autoreconnect is triggered to see why. the log you have supplied shows the client when its already in autoreconnect, this is too late.
from mqtt_client.
hello, @shamblett please look
2023-01-04 14:56:02.446 -- MqttBrowserWsConnection::connect - websocket is open
2023-01-04 15:14:53.868 -- MqttBrowserConnection::_startListening - websocket is closed
[Question]: is there any callback available that tells WebSocket goes into the reconnected(MqttBrowserWsConnection::connectAuto - WebSocket has errored) mode?
from mqtt_client.
The first two lines, show that at 14:56 you connected and at 15:14 the socket closed for some reason as you have spotted, so you have lost connection at the network level which is triggering auto reconnect, this should work however. There is an on Autoreconenct callback that is triggered when autoreconnect kicks in, there is also one when autoreconnect has completed, please see the API docs.
from mqtt_client.
ok. and how we can identifying why it's goes to reconnect. and why auto reconnect not able to connect successfully?
from mqtt_client.
Unfortunately the client cant tell you why it was disconnected as youvr seen from the logs the client just getsca socket event from the Dart runtime saying the socket has closed its not told why.
Autoreconnect should work however Ill do some testing to see if we have bug here for browser based connections.
from mqtt_client.
When you say 'working fine' do you mean in debug mode when the network disconnects and autoreconnect starts then the client does eventually re-connect or are you saying that the client doesn't disconnect in the first place?
The client package has no concept of debug or release mode, its just Dart code so whatever is happening I doubt if the client can help you with it.
from mqtt_client.
in debug mode client doesn't disconnect in the first place.
yes i know. but i share whatever i observed.
from mqtt_client.
@shamblett Any update?
is there any way to resolve this still we have received this WebSocket error?
Is it possible that when MQTT disconnects, it can connect automatically? Is there any solution?
from mqtt_client.
Hi @shamblett I'm facing the same issue on web too.
It's not possible to connect with the same client identifier again
the error stack points to this line https://github.com/shamblett/mqtt_client/blob/master/lib/src/connectionhandling/browser/mqtt_client_mqtt_browser_ws_connection.dart#L224
from mqtt_client.
sorry my errors were actually caused by the Backend π kubernetes were down
from mqtt_client.
This happens on Chrome-based browsers (edge, chrome...) after the tab is inactive for some time, It is some sort of optimization from Chrome, it doesn't happen on Mozilla and you cannot reproduce it (at least I think) in debug mode for some reason
https://solace.community/discussion/694/client-websocket-disconnects-when-browser-is-minimized-or-not-in-focus-chrome
from mqtt_client.
Related Issues (20)
- Hot reload causes infinite MQTT connect loop HOT 3
- Connection Lost When App Killed HOT 1
- Failed to connect to mqtt, I donβt know where the problem lies HOT 1
- mqtt sets reconnection timeout to expire HOT 30
- Need shorter timeout when connection can't be established HOT 9
- feat: Added a connection timeout callback HOT 8
- Add Connection Ack message to connection status HOT 1
- MqttBrowserClient with self-signed certificate HOT 1
- How to add proxy to see content in proxy tools like Charles/Proxyman? HOT 1
- retain:true publishing issue (using IoT Core) HOT 3
- Differences in automatic reconnection between IOS and Android HOT 1
- '400 Bad Request' response while connecting with websocket to rabbitmq HOT 3
- How to connect mqtt with socket header options? HOT 3
- mqttjs:client _checkPing :: checking ping... Runs twice in rapid succession some times HOT 1
- How to determine the cause of the disconnect? HOT 1
- Available bytes is less than the message size HOT 4
- error:Bad state: Cannot add new events after calling close HOT 8
- AWS IoT Certificate - Use .bks file certificate HOT 1
- NoConnectionException: Missing Connection Acknowledgement HOT 4
- Ping triggers client.update and brings the same message multiple times 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 mqtt_client.