title: How can I send a image by using mosquitto?
body: <p>I'm trying to send a jpg image using MQTT mosquitto broker(pub and sub) in Raspberry Pi2.</p>
  
  <p>This is my python code pub.py(modified)</p>
  
  <pre><code>import paho.mqtt.client as mqtt
  
  def on_publish(mosq, userdata, mid):
      mosq.disconnect()
  
  client = mqtt.Client()
  client.connect("test.mosquitto.org", 1883, 60)
  client.on_publish = on_publish
  
  f=open("b.jpg", "rb") #3.7kiB in same folder
  fileContent = f.read()
  byteArr = bytearray(fileContent)
  client.publish("image",byteArr,0)
  
  client.loop_forever()
  </code></pre>
  
  <p>and it's sub.py(modified)</p>
  
  <pre><code>import paho.mqtt.client as mqtt
  
  def on_connect(client, userdata, rc):
      print("Connect" + str(rc))
      client.subscribe("image") 
  
  def on_message(client, userdata, msg):
      print "Topic : ", msg.topic
      f = open("/tmp/output.jpg", "w")  #there is a output.jpg which is different
      f.write(msg.payload)
      f.close()
  
  client = mqtt.Client()
  client.on_connect = on_connect
  client.on_message = on_message
  
  client.connect("test.mosquitto.org", 1883, 60)
  
  client.loop_forever()
  </code></pre>
  
  <p>My python verson is 2.7.9.</p>
  
  <p>After I solved some error, It seems to work but It doesn't.</p>
  
  <p>When I implement the sub.py, It connects successfully so I implement the pub.py in other terminal.</p>
  
  <p>However, There isn't any reaction without connect message which is "Connect with result code 0"</p>
  
  <p>There is no error message so I don't know what my mistake is.</p>