I want to follow the example mentioned here to connect to a broker in Python. The code is just stuck at the instantiation part. No response, no nothing ! What could be wrong ?
pi@raspberrypi ~ $ python
Python 2.7.3 (default, Mar 18 2014, 05:13:23)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import paho.mqtt.client as mqtt
>>> c = mqtt.Client("random")
The mqtt.Client
doesn't ever complete. Since the connect method is yet to be called, I am not sure, if this could be a network issue. Nevertheless, a Ctrl-C
shows the following:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/paho/mqtt/client.py", line 422, in __init__
self._sockpairR, self._sockpairW = _socketpair_compat()
File "/usr/local/lib/python2.7/dist-packages/paho/mqtt/client.py", line 271, in _socketpair_compat
sock2, address = listensock.accept()
File "/usr/lib/python2.7/socket.py", line 202, in accept
sock, addr = self._sock.accept()
KeyboardInterrupt
>>>
This happens with python3
too.
UPDATE: This issue happens on the Raspberry Pi. On Ubuntu, the same code works fine.