Jump to content
Sign in to follow this  
Pat28

MQTT error [Errno 111] Connection refused

Recommended Posts

Hi,

On a raspberry pi with Jessie image (latest update and upgrades), python 2.7.9

 

installed brick MQTT proxy:

wget https://raw.githubusercontent.com/Tinkerforge/brick-mqtt-proxy/master/brick-mqtt-proxy.py

 

installed brick deamon:

sudo apt-get install libusb-1.0-0 libudev0 pm-utils

  wget http://download.tinkerforge.com/tools/brickd/linux/brickd_linux_latest_armhf.deb

  sudo dpkg -i brickd_linux_latest_armhf.deb

 

Brick deamon is working fine; I can see the values of the bricklets

 

Installed the Python API bindings:

sudo pip install tinkerforge

 

Installed  Eclipse Paho MQTT Python client library:

sudo pip install paho-mqtt     

 

Started the proxy with:

sudo python brick-mqtt-proxy.py

 

And receive this error:

 

pi@PI1:~ $ sudo python brick-mqtt-proxy.py

Traceback (most recent call last):

  File "brick-mqtt-proxy.py", line 1233, in <module>

    proxy.connect()

  File "brick-mqtt-proxy.py", line 1100, in connect

    self.client.connect(self.broker_host, self.broker_port)

  File "/usr/local/lib/python2.7/dist-packages/paho/mqtt/client.py", line 686, in connect

    return self.reconnect()

  File "/usr/local/lib/python2.7/dist-packages/paho/mqtt/client.py", line 808, in reconnect

    sock = socket.create_connection((self._host, self._port), source_address=(self._bind_address, 0))

  File "/usr/lib/python2.7/socket.py", line 571, in create_connection

    raise err

socket.error: [Errno 111] Connection refused

 

What did I do wrong?

 

Thanks

Patrick

 

 

 

 

 

Share this post


Link to post
Share on other sites

Hi,

 

I am using following steps on the Raspberry Pi:

  * sudo apt-get install python3-pip

  * sudo apt-get install python-pip

  * sudo pip install tinkerforge paho-mqtt

  * sudo apt-get install mosquitto mosquitto-clients python-mosquitto

  * sudo apt-get install libusb-1.0-0 libudev0 pm-utils

  * mkdir /home/pi/tinkerforge                                   

  * cd /home/pi/tinkerforge                                 

  * wget http://download.tinkerforge.com/tools/brickd/linux/brickd_linux_latest_armhf.deb

  * sudo dpkg -i brickd_linux_latest_armhf.deb

  * delete the file brickd_linux_latest_armhf.deb: rm brickd_linux_latest_armhf.deb 

  * Copy the file brick-mqtt-proxy.py to this folder after download from the TinkerForge website https://github.com/Tinkerforge/brick-mqtt-proxy

  * OR use wget https://raw.githubusercontent.com/Tinkerforge/brick-mqtt-proxy/master/brick-mqtt-proxy.py

  * Start the Brick-MQTT-Proxy as process: python brick-mqtt-proxy.py&

 

Share this post


Link to post
Share on other sites

Hi rwblinn,

 

Thanks for the instructions steps.

It works fine thanks to you.

 

I modified the last line:

python brick-mqtt-proxy.py --brickd-host 192.168.1.xxx --brickd-port 4223 --broker-host localhost --broker-port 1883 --update-interval 5& 

 

where xxx = ip address tinkerforge brick

and interval 5 to have a 5 seconds refresh.

 

Again , thanks for helping me solve this problem.

 

Patrick

Share this post


Link to post
Share on other sites

This error means that the client cannot connect to the port on the computer running server script.   This can be caused by few things, like lack of routing to the destination or you have a firewall somewhere between your client and the server - it could be on server itself or on the client etc. Note that a server must perform the sequence socket(), bind(), listen(), accept() (possibly repeating the accept() to service more than one client), while a client only needs the sequence socket(), connect(). Also note that the server does not sendall()/recv() on the socket it is listening on but on the new socket returned by accept(). Try the following:

  • Check if you really have that port listening on the server (this should tell you if your code does what you think it should): based on you OS, but on linux you could do something like netstat -ntulp
  • Check from the server, if you're accepting the connections to the server: again based on your OS, but telnet LISTENING_IP LISTENING_PORT should do the job
  • Check if you can access the port of the server from the client , but not using the code: just us the telnet (or appropriate command for your OS) from the client

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...