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

MQTT was disconnected due to badmatch error #188

Open
moluzhui opened this issue Apr 16, 2020 · 2 comments
Open

MQTT was disconnected due to badmatch error #188

moluzhui opened this issue Apr 16, 2020 · 2 comments

Comments

@moluzhui
Copy link

moluzhui commented Apr 16, 2020

I use mqtt acl table as follows

id allow ipaddr username clientid access topic
1 1 NULL test NULL 3 #

The following configuration has also been modified

allow_anonymous = false
acl_nomatch = deny
sed -i '/{allow, all}./d' /opt/emqx/etc/acl.conf  # delete {allow, all}.

and use emqx-auth-pgsql to certification.

There is no problem with the superuser but the following problem occurs with normal users such as test

Python MQTT as follows

def on_connect(client, userdata, flags, rc):
    logger.info("Connected with result code " + str(rc))
    if rc == 5:
        logger.critical("auth failed")
    client.subscribe(f"device1/#",2)
client = mqtt.Client(client_id = client_id)
client.on_connect = on_connect
client.username_pw_set(test,test)
client.connect(ip, port, 60)
client.loop_forever()

When I execute my python code, I keep output like this

INFO:main:Connected with result code 0
INFO:main:Connected with result code 0
INFO:main:Connected with result code 0
....

I subscribed to the system topic $SYS/brokers/+/clients/# and found that the python client had been connecting and then disconnected

{'clean_start': True, 'clientid': 'client_id', 'connack': 0, 'ipaddress': 'xxxx', 'keepalive': 60, 'proto_name': 'MQTT', 'proto_ver': 4, 'ts': 1587053466406, 'username': 'test'}
{'clientid': 'agent_eVEoS49gxJtspEKE2vkJtW', 'username': 'test', 'reason': 'badmatch', 'ts': 1587053466407}
.....

Where did I misconfigure this badmatch disconnect problem?

I used an emqx:v3.2.4 docker image

@HJianBo
Copy link
Member

HJianBo commented Apr 27, 2020

Hi @moluzhui Sorry for the late reply.

It seems the emqx deny the SUBSCRIBE operation and evict this client.

In the first, please make sure the acl_deny_action option of emqx.conf
second, Above these configurations, Should the emqx allow subscribing device1 /# topic? I你that case, Why should we confirm it ACL failure

@moluzhui
Copy link
Author

moluzhui commented Apr 27, 2020

@HJianBo
sorry, I didn't catch your second one

See emqx.conf results below

cat etc/emqx.conf | grep acl_deny_action
acl_deny_action = ignore
zone.external.acl_deny_action = ignore
zone.internal.acl_deny_action = ignore

What I want to implement is an MQTT message that a specific user can subscribe to and publish a specific topic based on the above configuration.

But based on the error case, it appears that test users cannot subscribe to the device1/# topic that I want them to be able to subscribe to.

Am I missing some configuration or adding the wrong configuration?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants