emqtt
emqtt copied to clipboard
Ability to refresh mqtt password at every reconnection
Hi, we have a scenario where every time we generate a password to the MQTT, this password may have some security constraints, i.e expiration time, depending on the MQTT module implementation.
Sometimes the tcp
connection may be closed or the emqttc
process might fail for any reason, then we'd like to use the same process to retry over again but using a different password.
This patch adds the ability to send a password_refresher
to the mqtt connection opts, a simple function which will be called at every connect/reconnect.
Usage
PasswordRefresher = fun() -> <<"logic to generate a new password">> end,
{ok, C} = emqttc:start_link([{host, "localhost"}, {password_refresher, PasswordRefresher}]).
cc @emqplus
up @emqplus
up @emqplus