Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot create a plugin to handle messages received through bridge #3163

Open
satel-kalletuulos opened this issue Nov 13, 2024 · 2 comments
Open
Labels
Status: Available No one has claimed responsibility for resolving this issue.

Comments

@satel-kalletuulos
Copy link

Mosquitto version: 2.0.18
Target environment: Yocto 4.0 (Kirkstone)

The device A running Mosquitto broker establishes bridge to device B. Purpose is to create a plugin to modify messages received through bridge.

I'm experimenting with the sample plugin from Mosquitto repository:
https://github.com/eclipse-mosquitto/mosquitto/blob/v2.0.18/plugins/payload-modification/mosquitto_payload_modification.c

I added debug print to callback_message function so I can see, when that message is called, as follows:

static int callback_message(int event, void *event_data, void *userdata)
{
	struct mosquitto_evt_message *ed = event_data;
	char *new_payload;
	uint32_t new_payloadlen;

	UNUSED(event);
	UNUSED(userdata);

    printf("Plugin callback message with topic %s\n", ed->topic);

System's /etc/mosquitto/mosquitto.conf file is as follows:

include_dir /etc/mosquitto/conf.d

On /etc/mosquitto/conf.d directory, there are following configuration files:

01-defaults.conf - contains just row per_listener_settings true

10-listener-all.conf - contains definitions for the default listener, currently following:

listener 1883
allow_anonymous true

20-default-bridge.conf - contains following:

connection default-bridge
address 10.10.100.10
topic # both 0 "" mydevice/

30-sample-plugin.conf - contains following:

listener 1884
allow_anonymous true
plugin /usr/lib/mosquitto_dynamic/sample_plugin.so

Notice that the plugin configuration file has to have additional listener, as otherwise it would open default listener for port 1883 and it would conflict for the existing listener.

For testing and debugging, Mosquitto broker is started with command line: mosquitto -c /etc/mosquitto/mosquitto.conf
From debug prints, it can be seen that the sample plugin is not called for messages arriving through bridge or for messages arriving from default listener on port 1883. Plugin is called only for messages arriving from port 1884.

Question: How can plugin be configured so that it would called for ALL messages, arriving from all ports and also from bridge?

@github-actions github-actions bot added the Status: Available No one has claimed responsibility for resolving this issue. label Nov 13, 2024
@Daedaluz
Copy link
Contributor

since per-listener settings is true, perhaps adding plugin /usr/lib/mosquitto_dynamic/sample_plugin.so to the 1883 listener helps?

@satel-kalletuulos
Copy link
Author

It does not help. The plugin is called only for messages sent through that specific listener.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Available No one has claimed responsibility for resolving this issue.
Projects
None yet
Development

No branches or pull requests

2 participants