Read permission error after MQTT Moquette Broker restarts with active client connection (Windows)

0

Our client's on_connection_resumed method initiates a new connection if no session is present. This works fine with IoT Core when the client loses connectivity.

However, when paired w/ Greengrass, we get the following error in greengrass.log on the FIRST reconnect attempt:

2022-08-19T21:14:24.480Z [WARN] (Session Executor 0) io.moquette.broker.Authorizator: Client does not have read permissions on the topic username: -----BEGIN CERTIFICATE-----
XXXXX
-----END CERTIFICATE-----
, messageId: 3, topic: /topic/path. {}

Here is the client code:

def on_connection_resumed(self, connection, return_code, session_present, **kwargs):
    if return_code == mqtt.ConnectReturnCode.ACCEPTED and not session_present:
        self.reconnect()

Reconnect is essentially calling a disconnect (OK if this fails) followed by a fresh connect:

try:
    disconnect_future = self._shadow_client.mqtt_connection.disconnect()
    disconnect_future.result(timeout=FUTURE_TIMEOUT)
except:
    ....
try:
    mqtt_connection = mqtt_connection_builder.mtls_from_path(...)
    connected_future = mqtt_connection.connect()
except:
    ....

The error above is only present after the first reconnect attempt. Subsequent reconnect attempts connect successfully.

Auth component is configured correctly (fully permissive policy)

  • Hi - can you also post logs leading up to this warning? I'm particularly interested in logs relating to "sessions". That will help us figure out if the issue is in the client device auth component, or if this is failing inside Moquette.

    I'm a bit confused why your client would initiate a new connection after receiving a connection resumed callback. Do you mean it re-subscribes if no session is present? Can you attach a code snippet? Thanks

  • Updated the initial comment w/ additional code snippets. For now, this is mitigated by catching the failed subscription and attempting (another) reconnect, which does complete successfully. This appears to be on the Moquette side, though I don't see any additional information in the logs.

  • Thank you for the additional information, we are attempting to reproduce the issue now.

asked 2 years ago101 views
No Answers

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions