0

I am new guy in use MQTT, when I publish message use qos=1 I could recevice message correct.but when I try to publish message use qos=2 I got nothing.this was my test code ,I try use rabbit mq (MQTT)
Subscribe:

def MQTT_CONNECTION():
    print("IN mqtt connection")
    client = mqtt.Client()
    client.username_pw_set(user, pwd) 
    client.connect("localhost", 1883, 60)
    client.on_connect = on_connect
    client.on_message = on_message
    client.subscribe([("TEST", 2)])
    MQTT_CLIENT_CONNECTED=True
    print('in function'+str(stop))
    client.loop_forever()
    except Exception as error:
        print("ERROR IN MQTT CONNECTION",error)
        MQTT_CLIENT_CONNECTED=False

Publish code:

client.publish("TEST",2111,qos=2,retain=True)

when the qos set to 1 subscribe code could receive messsage, when I try to change the qos =2 I got nothing Please give me some help . Thanks

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
james
  • 1
  • 1
  • Update the question with more of the publish code, you need to be running the client loop for QOS2 publishes because it's a multi step process. – hardillb Feb 26 '18 at 11:35
  • 1
    RabbitMQ doesn't support QoS2 and downgrades the QoS level to QoS1, see https://www.rabbitmq.com/mqtt.html. I don't know if that is the problem, but I could imagine a normal client would be confused by this. – Lars Hesel Christensen Feb 26 '18 at 16:11
  • Thanks for you help, I think that was reason .I need learning more about rabbit mq thanks again. – james Feb 27 '18 at 02:11

0 Answers0