Diversity plugin start before custom plugin

57 views
Skip to first unread message

Kedar Undale

unread,
Jul 6, 2021, 12:36:27 PM7/6/21
to vernemq-users
Hi , I have enabled diversity plugin for authentication of clients. I also have a custom erl plugin which handles on_register , on_client_online, on_client_offline , auth_on_register hooks. The auth_on_register hook redirects to the next available plugin. 

Issue : 
The custom erl plugin starts before the diversity plugin. The custom plugin also tries to connect to the vernemq broker using emqtt lib. But since the diversity plugin is not started the broker throws no_matching_hook found error. 

Doubts
1. How do I start the diversity plugin first and then start the custom plugin?
2. How do I send CONNACK once the auth is success

Anything will really helpful 

André Fatton

unread,
Jul 6, 2021, 12:59:38 PM7/6/21
to vernemq-users
Hi Kedar,
The chain will be based on starting order of the plugins:

So, for your case this probably just means that you start your plugin in a controlled manner, after Verne is up (I suppose you start vmq_diversity just via the vernemq.conf file).
For the MQTT connection, there'll be a little bit of a timing issue. Unfortunately there's no boot states (like status "internal plugins started", or the like).
I can't guess the details that your plugins does, but it looks like you'd have to handle that connect/re-connect logic from the client side, to ensure you have the proper connections and subscriptions set up.
Note that a plugin can also grab the MQTT messages flowing through the broker directly (that is, with internal subscriptions, instead of explicitly connecting over MQTT). The vmq_bridge plugin would be an example for that. Your approach is also a valid option, of course. (I suppose your plugin does auth and some form of re-publishing over MQTT)

Best,
André

Kedar Undale

unread,
Jul 6, 2021, 2:53:26 PM7/6/21
to vernemq-users
Hi Andre,
FYI 
1. My custom plugin just publishes a message to a topic, a java standalone client listens to that topic and updates the online offline states on a shared cache.
2. I have enabled client username password auth using diversity plugin with mysql. The authentication is success, but not able to send CONNACK back to client.
Getting the following error
Timeout while waiting for CONNACK
Using mqtt-cli 4.6.2 to connect to verne(broker)

3. 2021-07-06 18:48:00.643 [warning] <0.4530.0>@vmq_ql_query:select:209 Subquery failed due to timeout
2021-07-06 18:48:00.744 [warning] <0.4530.0>@vmq_ql_query:select:209 Subquery failed due to timeout
Getting this error when i run vmq-admin session show

Not sure where I am going wrong, anything will be really helpful.
Thank you
Reply all
Reply to author
Forward
0 new messages