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

Wildcard subscriptions not receiving anything (jwt auth for broker) #762

Open
MacherelR opened this issue Nov 27, 2023 · 1 comment
Open
Labels
Status: Available No one has claimed responsibility for resolving this issue. Status: More info needed More information needed from issue author

Comments

@MacherelR
Copy link

Hi,
I've deployed an EMQX cluster with the auth JWT plugin. Everything seems to work well as my client programm (written in python using paho.mqtt library) is able to connect to the broker and subscribe to a wildcard topic (in my case: E01/COMMANDS/#). Now the problem I'm facing is that whenever I publish a message on i.e E01/COMMANDS/REGISTER, the message is correctly received by the broker (see figure)

Screenshot 2023-11-27 at 3 31 02 PM

But those messages are never consumed by the client and therefore commands not treated... I was wondering whether anyone has faced this problem?
My subscription is handled the following way:

self.mqtt_username = DEVICE_ID
self.mqtt_password = response.json()['accessToken']
self.mqtt_broker_url = MQTT_BROKER_URL
self.mqtt_broker_port = MQTT_BROKER_PORT
self.mqtt_client = mqtt.Client(MQTT_CLIENT_ID, clean_session=False)
self.mqtt_client.username_pw_set(self.mqtt_username, self.mqtt_password)
self.mqtt_client.on_connect = self.on_connect
self.mqtt_client.on_message = self.on_message
self.mqtt_client.on_disconnect = self.on_disconnect
""" FOR Now, unused callbacks"""
self.mqtt_client.on_publish = self.on_publish
self.mqtt_client.on_subscribe = self.on_subscribe
self.mqtt_client.on_log = self.on_log
## Sets last will and testament to indicate if the is offline due to deconnection
self.mqtt_client.will_set(STATUS_TOPIC, payload="offline", qos=2, retain=True)
... 
...
self.mqtt_client.connect(self.mqtt_broker_url,
                                     port=self.mqtt_broker_port,
                                     keepalive=60,
                                     session_expiry=60)
self.mqtt_client.loop_start()
self._logger.info(f"MQTT client connected to broker {self.mqtt_broker_url}:{self.mqtt_broker_port}")

And the subscription is set in on_connect callback as following:

def on_connect(self,mqttc, obj, flags, rc):
        mqttc.subscribe(COMMAND_TOPIC,qos=1)
        self.mqtt_connection_on = True
        print("rc: " + str(rc))

Where COMMAND_TOPIC is 'E01/COMMANDS/#'

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

you're not providing enough information for anyone to say anything useful.

  • You claim the publish worked... graphic shows that somebody published something, how do you know it is the message that you published, or that the message is correct?
  • can you print the content of a sample message on the broker?
  • If the broker has no traffic you can set COMMAND_TOPIC to '#' and see if you get any messages.
  • You aren't checking the result of the subscribe... did the subscribe succeed?

@MattBrittan MattBrittan added the Status: More info needed More information needed from issue author label Dec 29, 2023
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. Status: More info needed More information needed from issue author
Projects
None yet
Development

No branches or pull requests

3 participants