moquette icon indicating copy to clipboard operation
moquette copied to clipboard

Broker restart and clear connections,but aslo can response client PINGEQ message

Open kscorpio opened this issue 1 year ago • 7 comments

Broker restart (less than 5 s ) and clear connections,but aslo can response client PINGEQ message,but getConnectedList is empty ,

the client set ping interval = 20s,

kscorpio avatar Mar 02 '23 06:03 kscorpio

Hi @kscorpio , please could you expand more on your problem? Do you want that the broker respond to the PING while restarting?

andsel avatar Mar 03 '23 14:03 andsel

moquette stopped and after 5 seconds restart, the client send ping ,the moquette can also response , but broker.listConnectedClients() is empty .

kscorpio avatar Apr 17 '23 05:04 kscorpio

when i restart broker , and call api getConnectionList , return empty but in the debug log ,has many line like below C->B PINGREQ < null > if the client is connected , the ping log should be C->B PINGREQ <'clientID'> @andsel

kscorpio avatar Apr 19 '23 08:04 kscorpio

MQTTConnection.class line 105

 case PINGREQ:
                String cid = NettyUtils.clientID(channel);
                if (!StringUtil.isNullOrEmpty(cid)) {
                    MqttFixedHeader pingHeader = new MqttFixedHeader(MqttMessageType.PINGRESP, false, AT_MOST_ONCE,
                        false, 0);
                    MqttMessage pingResp = new MqttMessage(pingHeader);
                    channel.writeAndFlush(pingResp).addListener(CLOSE_ON_FAILURE);
                }

maybe can resovle the problem ?

kscorpio avatar Apr 20 '23 01:04 kscorpio

Thank's @kscorpio for all this tests and investigations, I'll try to wrap up next weekend. Just for confirmation, does this happen on main branch?

andsel avatar Apr 20 '23 07:04 andsel

yes , 0.17-snopshot

can is use maven package get a temp jar to use. ?

kscorpio avatar Apr 21 '23 02:04 kscorpio

Hi @kscorpio I tried to reproduce the issue without any success. I improved the EmbeddedLauncher to exit or list_clients, please checkout PR #746 and start with:

./mvnw clean package exec:java -pl embedding_moquette

Using the HiveMQ CLI tool on broker restart, the client reconnects and the ping messages has all the clientid.

Press Ctl-C to exit.

Using default values from properties file /home/andrea/.mqtt-cli/config.properties:
Host: localhost, Port: 1883, Mqtt-Version MQTT_5_0, Logfile-Debug-Level: DEBUG
No Logfile used - Activate logging with the 'mqtt sh -l' option
mqtt> con -V 3 -h 127.0.0.1 -i andsel_pub -k 10
[email protected]> pub -t /temperature/milan -m 18
[email protected]> pub -t /command -m list_clients
[email protected]> Server closed connection without DISCONNECT.
Press ENTER to resume: 
mqtt> con -V 3 -h 127.0.0.1 -i andsel_pub -k 10

Do you have a reproducer, or could you use the EmbeddedLauncher to verify your client? Maybe it depends on the way the embedded broker instance is managed, could describe more or provide a local reproducer, please?

andsel avatar May 01 '23 13:05 andsel