尝试使用 paho-mqtt 订阅主题时出现错误 128 (0x80)
Error 128 (0x80) while trying to subscribe to topic with paho-mqtt
hbmqtt 0.9.6 I'm using as a broker and paho-mqtt 1.5.1 作为客户。它们都支持 MQTT v3.1.1.
经纪人配置:
listeners:
default:
type: tcp
halp:
max-connections: 33
bind: 127.0.0.3:1883
topic-check:
enabled: false
auth:
allow-anonymous: true
客户代码:
import paho.mqtt.client as mqtt
def on_connect(client, userdata, flags, rc):
print("Connected with result code "+str(rc))
client.subscribe('abc')
def on_message(client, userdata, msg):
print(msg.topic + " " + str(msg.payload))
def on_subscribe(mosq, obj, mid, qos):
print("Subscribed: " + str(mid))
print("Granted QoS: " + str(qos[0]))
client = mqtt.Client(client_id="subscriber", transport="tcp")
client.on_connect = on_connect
client.on_message = on_message
client.on_subscribe = on_subscribe
client.connect("127.0.0.3", 1883)
client.loop_forever()
客户端正确地建立了与代理的连接,并且可以毫无问题地向代理发送消息。但是当我尝试订阅主题时,我收到 Granted QoS: 128
。什么会导致这种问题?
我试过的:
- 更改主题名称
- 更改端口ip/port
- 将传输从 tcp 更改为 ws
- 更改 OS(在 Armbian 和 Ubuntu 上试过)
- 使用 login:password
的身份验证
Fraschbi 是对的。问题出在指定版本的 hbmqtt 上:它忽略了权限配置。解决方法是指定客户端可以订阅哪些主题
hbmqtt 0.9.6 I'm using as a broker and paho-mqtt 1.5.1 作为客户。它们都支持 MQTT v3.1.1.
经纪人配置:
listeners:
default:
type: tcp
halp:
max-connections: 33
bind: 127.0.0.3:1883
topic-check:
enabled: false
auth:
allow-anonymous: true
客户代码:
import paho.mqtt.client as mqtt
def on_connect(client, userdata, flags, rc):
print("Connected with result code "+str(rc))
client.subscribe('abc')
def on_message(client, userdata, msg):
print(msg.topic + " " + str(msg.payload))
def on_subscribe(mosq, obj, mid, qos):
print("Subscribed: " + str(mid))
print("Granted QoS: " + str(qos[0]))
client = mqtt.Client(client_id="subscriber", transport="tcp")
client.on_connect = on_connect
client.on_message = on_message
client.on_subscribe = on_subscribe
client.connect("127.0.0.3", 1883)
client.loop_forever()
客户端正确地建立了与代理的连接,并且可以毫无问题地向代理发送消息。但是当我尝试订阅主题时,我收到 Granted QoS: 128
。什么会导致这种问题?
我试过的:
- 更改主题名称
- 更改端口ip/port
- 将传输从 tcp 更改为 ws
- 更改 OS(在 Armbian 和 Ubuntu 上试过)
- 使用 login:password 的身份验证
Fraschbi 是对的。问题出在指定版本的 hbmqtt 上:它忽略了权限配置。解决方法是指定客户端可以订阅哪些主题