[ 
https://issues.apache.org/jira/browse/ARTEMIS-5540?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Justin Bertram resolved ARTEMIS-5540.
-------------------------------------
    Fix Version/s: 2.42.0
       Resolution: Fixed

> clarify doc for MQTT default session expiry interval
> ----------------------------------------------------
>
>                 Key: ARTEMIS-5540
>                 URL: https://issues.apache.org/jira/browse/ARTEMIS-5540
>             Project: ActiveMQ Artemis
>          Issue Type: Bug
>    Affects Versions: 2.41.0
>            Reporter: Rich T
>            Priority: Major
>             Fix For: 2.42.0
>
>
> The {{MQTTStateManager}} {{scanSessions}} logic only seems to clear out 
> sessions if the timeout is greater than 0 but this doesn't align with the 
> documentation:
> {quote}The default {{defaultMqttSessionExpiryInterval}} is {{-1}} which means 
> no MQTT 3.x session states will be expired and no MQTT 5 session states which 
> do not pass their own session expiry interval will be expired. Otherwise it 
> represents the number of *seconds* which must elapse after the client has 
> disconnected before the broker will remove the session state.{quote}
> Based on this information I would expect a value of {{0}} to expire a 
> disconnected session on next {{scanSessions}} execution but instead a value 
> of {{0}} appears to behave like a value of {{-1}}.
> Copy of code in question:
> {code:java}
> public void scanSessions() {
>    List<String> toRemove = new ArrayList();
>    for (Map.Entry<String, MQTTSessionState> entry : sessionStates.entrySet()) 
> {
>       MQTTSessionState state = entry.getValue();
>       logger.debug("Inspecting session: {}", state);
>       int sessionExpiryInterval = state.getClientSessionExpiryInterval();
>       if (!state.isAttached() && sessionExpiryInterval > 0 && 
> state.getDisconnectedTime() + (sessionExpiryInterval * 1000) < 
> System.currentTimeMillis()) {
>          toRemove.add(entry.getKey());
>       }
>       if (state.isWill() && !state.isAttached() && state.isFailed() && 
> state.getWillDelayInterval() > 0 && state.getDisconnectedTime() + 
> (state.getWillDelayInterval() * 1000) < System.currentTimeMillis()) {
>          state.getSession().sendWillMessage();
>       }
>    }
>    for (String key : toRemove) {
>       try {
>          MQTTSessionState state = removeSessionState(key);
>          if (state != null) {
>             if (state.isWill() && !state.isAttached() && state.isFailed()) {
>                state.getSession().sendWillMessage();
>             }
>             state.getSession().clean(false);
>          }
>       } catch (Exception e) {
>          MQTTLogger.LOGGER.failedToRemoveSessionState(key, e);
>       }
>    }
> } {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information, visit: https://activemq.apache.org/contact


Reply via email to