title: mqtt not publishing data onto the broker when qos set to 2
body: <p>client.publish(&quot;topic&quot;, payload,qos=2) not publishing data onto the broker whereas the same is working for qos=0 and 1.I have not defined persistence, it is set to default value.</p>
  <pre><code>import paho.mqtt.publish as publish
  
  import paho.mqtt.client as mqtt
  
  from random import *
  
  import time
  MQTT_IP='192.168.0.23'
  MQTT_PORT=1883
  global client
  import datetime
  def on_connect(client, userdata, flags, rc,qos):
  
      if rc==0:
          print(&quot;MQTT CONNECTION ESTABLISHED&quot;)
      print(str(client)+'\n'+str(userdata))
          
  def on_message(client, userdata, msg):
      print(&quot;Message arrived from &quot;+str(client))
      print(msg.topic+&quot; &quot;+str(msg.payload))
  
  def MQTT_CONNECTION():
      global client
      global MQTT_CLIENT_CONNECTED
      try:
          print(&quot;IN mqtt connection&quot;)
          client = mqtt.Client()
          client.connect(MQTT_IP,MQTT_PORT)
          client.on_connect = on_connect
          client.on_message = on_message
          MQTT_CLIENT_CONNECTED=True
  
      except Exception as error:
          print(&quot;ERROR IN MQTT CONNECTION&quot;,error)
          MQTT_CLIENT_CONNECTED=False
  def publish():
      global client
      client.publish(&quot;1/MB/EM/3/21/IB&quot;,2,qos=2,retain=True)    
  
  if __name__==&quot;__main__&quot;:
      MQTT_CONNECTION()
      publish()
  </code></pre>
  <p>I have removed all other functionality, for you all to understand better.</p>