halfgaar / FlashMQ

FlashMQ is a fast light-weight MQTT broker/server, designed to take good advantage of multi-CPU environments
https://www.flashmq.org/
Open Software License 3.0
174 stars 24 forks source link

support mosquitto style plugins #21

Closed mntnclmbr closed 1 year ago

mntnclmbr commented 1 year ago

I was trying to use some sample plugins from mosquitto with flashmq but it failed to load.

There are two issues here i think:

  1. the plugin failed to load
  2. flashmq shutdown instead of just rejecting the plugin, logging the error and loading up. It probably is by design to make sure user understand the plugin did not load, but seemed something worth mentioning in the documentation.

plugin in question : https://github.com/eclipse/mosquitto/tree/master/plugins/payload-modification

feel free to close if above is expected and by design

error log:

[2022-12-01 17:43:29] [NOTICE] Loading auth plugin /home/ubuntu/mosquitto/mosquitto/plugins/payload-modification/mosquitto_payload_modification.so [2022-12-01 17:43:29] [ERROR] Error initializing auth back-end: /home/ubuntu/mosquitto/mosquitto/plugins/payload-modification/mosquitto_payload_modification.so: undefined symbol: mosquitto_callback_register [2022-12-01 17:43:29] [NOTICE] Quitting FlashMQ

halfgaar commented 1 year ago

Thanks for the report.

The root problem is that FlashMQ only supports plugin version 2, from the Mosquitto 1.x branch. This is unlikely to change, because newer Mosquitto plugin versions are quite different. It was just easy to add support for version 2, so that was added.

But, FlashMQ's error detecting/reporting was lacking. So, that's been improved. It now properly reports the actual problem:

[2022-12-01 21:12:18] [NOTICE] Loading auth plugin /bla/mosquitto/plugins/examples/payload-modification/mosquitto_payload_modification.so
[2022-12-01 21:12:18] [ERROR] Error initializing auth back-end: This does not seem to be a FlashMQ native plugin or Mosquitto plugin version 2.

As for shutting down or failing silently: it's by design it shuts down. If the authentication system fails to load, there is no mode in which you can run: allowing all is unsafe. Allowing none is the same as not running at all.

The fix is in master, but is not important enough to warrant a new release.