[
https://issues.apache.org/jira/browse/ARTEMIS-5540?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17984981#comment-17984981
]
Justin Bertram commented on ARTEMIS-5540:
-----------------------------------------
Do you have a test that demonstrates this problem? I ask, because my reading of
the code as well as at least one existing test (i.e.
{{o.a.a.a.t.i.mqtt5.spec.controlpackets.ConnAckTests#testCleanStartFalseWithAbsentSessionExpiryInterval}})
indicate this is not a problem.
I think you're missing the relevant logic in
{{o.a.a.a.c.p.mqtt.MQTTConnectionManager#connect}} and
{{o.a.a.a.c.p.mqtt.MQTTSession#stop}}.
The only problem I see here is with the documentation, and [a
PR|https://github.com/apache/activemq-artemis/pull/5785] has been sent to deal
with that.
> MQTTStateManager scanSessions expects sessionExpiryInterval to be greater
> than 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
> Priority: Major
>
> 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