[ 
https://issues.apache.org/jira/browse/ARTEMIS-5540?focusedWorklogId=973066&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-973066
 ]

ASF GitHub Bot logged work on ARTEMIS-5540:
-------------------------------------------

                Author: ASF GitHub Bot
            Created on: 24/Jun/25 19:03
            Start Date: 24/Jun/25 19:03
    Worklog Time Spent: 10m 
      Work Description: jbertram opened a new pull request, #5796:
URL: https://github.com/apache/activemq-artemis/pull/5796

   (no comment)




Issue Time Tracking
-------------------

            Worklog Id:     (was: 973066)
    Remaining Estimate: 0h
            Time Spent: 10m

> Expire MQTT 3.x session immediately when defaultMqttSessionExpiryInterval is 0
> ------------------------------------------------------------------------------
>
>                 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
>            Assignee: Justin Bertram
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> 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: issues-unsubscr...@activemq.apache.org
For additional commands, e-mail: issues-h...@activemq.apache.org
For further information, visit: https://activemq.apache.org/contact


Reply via email to