Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[paho-dev] Resource temporarily unavailable

Hi, new to the list, new to mqtt, loving it so far.

I have small message feeds working great, both publish and subscribe, now Im trying to publish a ~90KB file and am getting what looks like a socket error on loop, see below.

from searching the issue I found a loop_forever is needed when sending binaries/files, when i added the loop_forever, the resource unavailable error started. without the loop_forever, the file just wouldn’t send, the client would exit immediately with nothing sent.

Any input or feedback much appreciated.

client OS is angstrom linux

~# python pushcap.py 
Traceback (most recent call last):
  File "pushcap.py", line 20, in <module>
    rc = mqttc.loop(2)
  File "/usr/lib/python2.7/site-packages/paho/mqtt/client.py", line 790, in loop
    self._sockpairR.recv(1)
socket.error: [Errno 11] Resource temporarily unavailable

here’s my client code

:~# cat pushcap.py
import paho.mqtt.client as mqtt

def on_publish(foo, userdata, bar):
  # Disconnect after our message has been sent.
    print "published"
    mqttc.disconnect()

mqttc = mqtt.Client()
mqttc.on_publish = on_publish
mqttc.connect("broker", 1883, 60)
mqttc.loop_start()

f = open("cap.jpg")
imagestring = f.read()
byteArray = bytes(imagestring)
mqttc.publish("caps", byteArray, 1) # tried 0 and 1, no change
#mqttc.loop_forever()		    # tried loop_forever and the below rc checking loop
rc = 0
while rc == 0:
	    rc = mqttc.loop(2)     # tried () and (2), no change
	    print("rc: " + str(rc))



Back to the top