mosquitto disconnect the client when subscribe is not authorized

Created on 5 Nov 2018  路  7Comments  路  Source: eclipse/mosquitto

Hello

The problem is when user try to connect to the broker its work normally but when he try to subscribe to unauthorized topic the package disconnecting the user socket from broker, its happened only with subscribe, publish works fine.

123

Backend log
1234

mqtt client app

`
var mqtt = require('mqtt');

var mqttClient = mqtt.connect('mqtt://localhost:1883', {
username: "device_1",
password: "secret",
});

mqttClient.on('connect', function () {
mqttClient.subscribe("topic2");
console.log("App connected to MQTT Broker!");
});
`

p.s: same result in auth-plug and go-auth packages.

Thanks.

bug mosquitto-broker pending-close

Most helpful comment

Testing with my own golang plugin: returning false from mosquitto_auth_acl_check when access flag is MOSQ_ACL_SUBSCRIBE will indeed result in "Socket error on client", but not when it's MOSQ_ACL_READ.
Running a minimal plugin in c display the same behavior.
https://github.com/Daedaluz/mosquitto_plugin_template_c
mosquitto_sub continues to reconnect when using the plugin.

Just tried with tag v1.5.3

All 7 comments

Could you provide some more details on the configuration you're using please?

@ralight Thanks for your response.

Its default configuration nothing changed in mosquitto.conf file I have just added auth data

auth_plugin /home/ubuntu/mosquitto/go-auth.so
auth_opt_backends http
auth_opt_http_host 127.0.0.1
auth_opt_http_port 3000
auth_opt_http_getuser_uri /auth/mqtt/check
auth_opt_http_superuser_uri /auth/mqtt/superuser
auth_opt_http_aclcheck_uri /auth/mqtt/acl

auth package owner said its from mosquitto.

auth packager said it's from mosquitto what? There's no go-auth.so package provided here at least. Are you sure the plugin is not crashing on something unexpected and that's causing it to drop things?

@karlp
I tried these two packages:

https://github.com/jpmens/mosquitto-auth-plug
https://github.com/iegomez/mosquitto-go-auth

mosquitto-go-auth issue:
https://github.com/iegomez/mosquitto-go-auth/issues/10#issuecomment-435880410

same result client disconnect when he try to subscribe to unauthorized topic.
if the topic is authorized it's works fine.

Testing with my own golang plugin: returning false from mosquitto_auth_acl_check when access flag is MOSQ_ACL_SUBSCRIBE will indeed result in "Socket error on client", but not when it's MOSQ_ACL_READ.
Running a minimal plugin in c display the same behavior.
https://github.com/Daedaluz/mosquitto_plugin_template_c
mosquitto_sub continues to reconnect when using the plugin.

Just tried with tag v1.5.3

Thanks for the description @ibrahimkoujar and for confirming @Daedaluz. This should now be fixed in the fixes branch, could you check and close the issue if it's working for you?

Thanks for you @ralight @Daedaluz , problem has been resolved :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ralight picture ralight  路  5Comments

HenryNe picture HenryNe  路  5Comments

korish picture korish  路  7Comments

oej picture oej  路  7Comments

Andreyooo picture Andreyooo  路  5Comments