Skip to content

Question/Feat: Expose MQTT Client connection status #2219

@WizMe-M

Description

@WizMe-M

Which project is your feature request related to?

  • Client

Describe your question

IMqttClient exposes bool IsConnected property. In default implementation it calculates as (MqttClientConnectionStatus)_connectionStatus == MqttClientConnectionStatus.Connected.

So question is why not expose ConnectionStatus directly?

WHY?

Disconnection happened or keepalive failed - need to reconnect.
Even if I IsConnected prop have been checked there can be case that reconnect shouldn't/mustn't be called (eg in case of client is connecting already)

It would be nice to have public MqttClientConnectionStatus ConnectionStatus { get; } in IMqttClient (there) and it's impl in MqttClient.

Or at least documentation for MQTT-client functional. It's very unclear of what happening inside package:

  • What happen if Keep Alive task can't ping server - is there disconnect, disconnect+reconnect, some exception raised?
  • Should I reconnect manually if client had been disconnected? Inside of DisconnectedEvent handler mentioned here?
  • How can I know there is already a connection establishing (_connectionStatus == Connecting) without accessing to _connectionStatus? How can I avoid situations where a client is connecting but for some reason I will do ConnectAsync/ReconnectAsync?

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionIt is a question regarding the project

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions