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

Out of memory on mosquitto running on windows since 2.0.0 version #2111

Closed
yellowgg2 opened this issue Mar 4, 2021 · 6 comments
Closed

Out of memory on mosquitto running on windows since 2.0.0 version #2111

yellowgg2 opened this issue Mar 4, 2021 · 6 comments
Milestone

Comments

@yellowgg2
Copy link

yellowgg2 commented Mar 4, 2021

Steps to make it happen:

  1. install 2.0.x mosquitto on Windows 10.
  2. publish topic starting with dollar sign (ex: $CONNECTED/APISERVER) including retain option on
  3. You will be able to see Out of memory on broker log
    image

Hello,

I've been publishing topic starting with dollar sign like $CONNECTED/APISERVER including retain option on.

It worked with 1.6.9 version for windows, but since 2.0.0 it doesn't work and show out of memory error on mosquitto.

If retain option is OFF on client, it works well. It only happens with retain option ON for the topic.

Thank you!

@Tifaifai
Copy link
Contributor

Tifaifai commented Mar 4, 2021

Hello,
I am astonished because since version 1.6.9 the function acl__check_dollar() has not changed (static int acl__check_dollar(const char *topic, int access) in src/security.c ). It allows only the topics $SYS and $share.
Have you original version of mosquitto ?
C-Y

@yellowgg2
Copy link
Author

yellowgg2 commented Mar 5, 2021

Hello,
I am astonished because since version 1.6.9 the function acl__check_dollar() has not changed (static int acl__check_dollar(const char *topic, int access) in src/security.c ). It allows only the topics $SYS and $share.
Have you original version of mosquitto ?
C-Y

Hello,

I've been using mosquitto as Windows Binary downloaded from https://mosquitto.org/download/. I didn't customize source code at all.

With all the windows binary mosquitto, dollar sign is still working with any topic without any problem.
The point is that this error only happens with retain option ON when publishing.

According to your comment, any topic with dollar sign is not allowed intentionally. Do I understanding correctly?

By the way, once I looked at the code as you mentioned, it looks like any topic with dollar sign will return MOSQ_ERR_SUCCESS which means allow I guess...

Thank you.

static int acl__check_dollar(const char *topic, int access) {
        ...
// Line 672~674
        }else{
		/* This is an unknown $ topic, for the moment just defer to actual tests. */
		return MOSQ_ERR_SUCCESS;
	}
}

@ralight
Copy link
Contributor

ralight commented Mar 5, 2021

I've tried to reproduce this, but with no luck. Could you share your config please?

You're correct that publishing to $ topics is allowed except if ACLs deny them.

The out of memory message is almost certainly not correct, it will be down to a failure somewhere incorrectly returning a 1, which is the code for out of memory. If you share your config I hope we can get to the bottom of it.

@yellowgg2
Copy link
Author

I've tried to reproduce this, but with no luck. Could you share your config please?

You're correct that publishing to $ topics is allowed except if ACLs deny them.

The out of memory message is almost certainly not correct, it will be down to a failure somewhere incorrectly returning a 1, which is the code for out of memory. If you share your config I hope we can get to the bottom of it.

I am using self-signed certification and generated the password file with mosquitto_passwd.

This is the configuration all I got.

listener 23884
allow_anonymous false
password_file c:\brokerpassword
cafile c:\certs\mqtt_ca.crt
certfile c:\certs\mqtt_srv.crt
keyfile c:\certs\mqtt_srv.key

I am using Nodejs with MQTT.js as a client lib.

I am publishing data like below.

client?.publish("$CONNECTED/APISERVER", "true", {
   qos: 0,
   retain: true
});

As I mentioned before, it won't happen without retain option. It only happens with retain: true.

I also tested with MQTTFx as a client with 2.0.0 ~ 2.0.8 windows mosquitto binary and it happens as well.

Thank you for your help.

ralight added a commit that referenced this issue Mar 6, 2021
@ralight
Copy link
Contributor

ralight commented Mar 6, 2021

Thank you - sorry I hadn't realised the importance of it being a retained message. I've fixed this now, it is on the fixes branch and will be part of 2.0.9 in a week or so.

@ralight ralight added this to the 2.0.9 milestone Mar 6, 2021
@yellowgg2
Copy link
Author

I am so glad that you fixed it.
Thank you! :)

@ralight ralight closed this as completed Mar 11, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants