moquette-io / moquette

Java MQTT lightweight broker
http://moquette-io.github.io/moquette/
Apache License 2.0
2.3k stars 818 forks source link

io.moquette.broker.SessionCorruptedException: Session has already changed state: Session{clientId='xxx', clean=true, status=CONNECTING, inflightSlots=10} #821

Open blankbro opened 7 months ago

blankbro commented 7 months ago

Expected behavior

no exception

Actual behavior

throw io.moquette.broker.SessionCorruptedException

Steps to reproduce

  1. client send connect
  2. server send connack, but send failed

Minimal yet complete reproducer code (or URL to code) or complete log file

io.moquette.broker.SessionCorruptedException: Session has already changed state: Session{clientId='xxx', clean=true, status=CONNECTING, inflightSlots=10} at io.moquette.broker.SessionRegistry.purgeSessionState(SessionRegistry.java:415) at io.moquette.broker.SessionRegistry.connectionClosed(SessionRegistry.java:403) at io.moquette.broker.MQTTConnection$1.operationComplete(MQTTConnection.java:321)

Moquette MQTT version

0.17

JVM version (e.g. java -version)

1.8

OS version (e.g. uname -a)

mac & linux

blankbro commented 7 months ago

maybe add filedConnection() to Session.java

    boolean filedConnection() {
        return assignState(Session.SessionStatus.CONNECTING, Session.SessionStatus.DISCONNECTED);
    }

and add bindedSession.filedConnection() before MQTTConnection.java:321

    bindedSession.filedConnection();
    sessionRegistry.connectionClosed(bindedSession); // MQTTConnection.java:321
andsel commented 6 months ago

@blankbro thanks for reporting this. Do you have some simple way to test and reproduce locally the same error?

blankbro commented 6 months ago

@blankbro thanks for reporting this. Do you have some simple way to test and reproduce locally the same error?

😅 No, I don't.