Skip to main content

MQTT Client Configuration

As we have seen earlier, MqttClient requires an instance of MqttV3Configuration. MqttV3Configuration allows you to configure the following properties of MqttClient:

Required Configs

  • MqttPingSender : It is an implementation of MqttPingSender interface, which defines the logic of sending ping requests over the MQTT connection. Read more ping sender here.

  • Authenticator : MqttClient uses Authenticator to refresh the connect options when username or password are incorrect. Read more Authenticator here.

Optional Configs

  • Retry Policies : There are multiple retry policies used in Courier library - connect retry policy, connect timeout policy, subscription policy. You can either use the in-built policies or provide your own custom policies.

  • Logger : An instance of ILogger can be passed to get the internal logs.

  • Event Handler : EventHandler allows you to listen to all the library events like connect attempt/success/failure, message send/receive, subscribe/unsubscribe.

  • Mqtt Interceptors : By passing mqtt interceptors, you can intercept all the MQTT packets sent over the courier connection. This is also used for enabling MQTT Chuck.

  • Persistence Options : It allows you to configure the offline buffer present inside Paho. This buffer is used for storing all the messages while the client is offline.

  • Experimentation Configs : These are the experiment configs used inside Courier library which are explained in detail here.

  • WakeLock Timeout : When positive value of this timeout is passed, a wakelock is acquired while creating the MQTT connection. By default, it is 0.