Closed lucasjinreal closed 6 months ago
The client doesn't 'drop' connections, it simply listens for events from the underlying Dart/flutter runtime and reacts to them. If it receives say an onDone event from the network it closes its connection. There are many reasons why this event could be generated, network issues, broker issues etc. You could start by looking at your broker logs to see what it is doing when the connection is lost.
@shamblett The phenomenon is sporadic, I don't know why either, but I think it may be caused by some kind of time synchronization problem. For example, if I set auto connect and keep alive = 15s, could this cause the client to repeatedly connect to the server under such circumstances?
No, as I've said above when the client connects it then waits for events from the run time, it doesn't matter what you have set connection parameters to, brokers usually check these on connection anyway and refuse the connection if anything is wrong.
After that its up to the broker what to do, the keep alive is a keep alive from the client i.e. it monitors if the broker is available, the broker doesn't monitor the client as such.
Autoreconnect will keep trying if it can't connect, it doesn't matter what keep alive parameters you set, if you are finding that autoreconnect is taking a while it indicates a network/broker problem. Autoreconnect uses the same connect message you sent to the broker on initial connection so this message has already been validated by the broker.
Again, only your broker logs can tell you whats happening.
this is really hard to debug, since the broker has millions of messages and this only happen sometimes, can not make it happen every time.
and once it happens, it will keep connect -> disconnect -> connecting -> connected -> disconnected -> connecting.... forver repeat.
I though this shouldn't happen either.
I not saying that this has something wrong client, but I don't why the server will drop after it connects,
and this happen only casually, most of time it's normal, which could be the reason caused this?