Skip to content

Is LoggerType intended as the official way to observe connection lifecycle events (CONNACK success/failure, disconnect, transport errors)? #45

@Greendogo

Description

@Greendogo

We’re integrating boost::mqtt5::mqtt_client and need a reliable way to react to connection lifecycle transitions (e.g., set internal “connected/offline” state, emit telemetry, detect misconfiguration).

From the docs:

  • mqtt_client doesn’t expose connect/async_connect; async_run starts the connection attempt(s).
  • The auto-reconnect design can hide persistent misconfiguration, and the docs suggest using the logging mechanism to detect those cases.

We also see mqtt_client has a LoggerType template parameter, and the LoggerType concept allows implementing any subset of callbacks such as:
at_resolve, at_tcp_connect, at_tls_handshake, at_ws_handshake, at_transport_error, at_connack, at_disconnect, at_ws_handshake.

Questions:

  1. Is supplying a custom LoggerType the intended/official extension point to observe these lifecycle events (beyond printing debug output)?
  2. If yes, is it considered acceptable to use LoggerType callbacks for application state (e.g., raising events/flags), or is LoggerType meant strictly for diagnostics?
  3. If no, is there another recommended pattern/API for “connected / reconnecting / disconnected” signals (or would you consider adding one)?

Implementation-wise, our plan is to provide a LoggerType that forwards at_* calls to std::function callbacks (so we can hook at_connack/at_disconnect/etc.). Does that align with the library’s intended paradigm?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions