Code Monkey home page Code Monkey logo

Comments (22)

MurtuzaSrashtaSoft avatar MurtuzaSrashtaSoft commented on August 30, 2024 1

@shamblett

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.

shamblett avatar shamblett commented on August 30, 2024

OK, I'll need a client log to see whats happening here although this particular problem hasn't been reported before.

from mqtt_client.

divyeshDev avatar divyeshDev commented on August 30, 2024

Hello, @shamblett

please look client logs:

Screenshot 2022-12-28 at 1 30 37 PM

from mqtt_client.

shamblett avatar shamblett commented on August 30, 2024

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.

divyeshDev avatar divyeshDev commented on August 30, 2024

@shamblett For more than 30 minutes we do nothing on the web. Then we receive WebSocket error.

from mqtt_client.

shamblett avatar shamblett commented on August 30, 2024

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.

divyeshDev avatar divyeshDev commented on August 30, 2024

No, I didn't turn off the network.
the network is continuously on my pc.

from mqtt_client.

shamblett avatar shamblett commented on August 30, 2024

Ok, in that case when the autoreconnect sequence starts can you still ping your broker?

from mqtt_client.

divyeshDev avatar divyeshDev commented on August 30, 2024

no, not.
@shamblett please see attached photo

Screenshot 2022-12-28 at 4 33 51 PM

from mqtt_client.

shamblett avatar shamblett commented on August 30, 2024

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.

MurtuzaSrashtaSoft avatar MurtuzaSrashtaSoft commented on August 30, 2024

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.

shamblett avatar shamblett commented on August 30, 2024

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.

divyeshDev avatar divyeshDev commented on August 30, 2024

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

Screenshot 2023-01-04 at 3 55 42 PM

[Question]: is there any callback available that tells WebSocket goes into the reconnected(MqttBrowserWsConnection::connectAuto - WebSocket has errored) mode?

from mqtt_client.

shamblett avatar shamblett commented on August 30, 2024

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.

MurtuzaSrashtaSoft avatar MurtuzaSrashtaSoft commented on August 30, 2024

ok. and how we can identifying why it's goes to reconnect. and why auto reconnect not able to connect successfully?

from mqtt_client.

shamblett avatar shamblett commented on August 30, 2024

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.

shamblett avatar shamblett commented on August 30, 2024

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.

MurtuzaSrashtaSoft avatar MurtuzaSrashtaSoft commented on August 30, 2024

in debug mode client doesn't disconnect in the first place.

yes i know. but i share whatever i observed.

from mqtt_client.

divyeshDev avatar divyeshDev commented on August 30, 2024

@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.

ashley-arta avatar ashley-arta commented on August 30, 2024

Hi @shamblett I'm facing the same issue on web too.
It's not possible to connect with the same client identifier again

image
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.

ashley-arta avatar ashley-arta commented on August 30, 2024

sorry my errors were actually caused by the Backend πŸ™‡ kubernetes were down

from mqtt_client.

uberchilly avatar uberchilly commented on August 30, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.