Bottesford Posted September 26, 2017 at 09:19 AM Share Posted September 26, 2017 at 09:19 AM I'm looking to open up my sensor network to MQTT and am trying to get the proxy to work. I followed instructions to get it running on my Raspberry Pi inc the ones I found here: https://www.tinkerunity.org/forum/index.php/topic,3926.msg23435.html I've updated everything on the Pi - latest brickd, latest brickv, bindings, etc. But I'm getting this: Exception in thread Thread-1: Traceback (most recent call last): File "/usr/lib/python2.7/threading.py", line 552, in __bootstrap_inner self.run() File "/usr/lib/python2.7/threading.py", line 505, in run self.__target(*self.__args, **self.__kwargs) File "/usr/local/lib/python2.7/dist-packages/paho/mqtt/client.py", line 2606, in _thread_main self.loop_forever(retry_first_connection=True) File "/usr/local/lib/python2.7/dist-packages/paho/mqtt/client.py", line 1470, in loop_forever rc = self.loop(timeout, max_packets) File "/usr/local/lib/python2.7/dist-packages/paho/mqtt/client.py", line 995, in loop rc = self.loop_read(max_packets) File "/usr/local/lib/python2.7/dist-packages/paho/mqtt/client.py", line 1275, in loop_read return self._loop_rc_handle(rc) File "/usr/local/lib/python2.7/dist-packages/paho/mqtt/client.py", line 1754, in _loop_rc_handle self.on_disconnect(self, self._userdata, rc) File "brick-mqtt-proxy.py", line 1168, in mqtt_on_disconnect self.ipcon.disconnect() File "/usr/local/lib/python2.7/dist-packages/tinkerforge/ip_connection.py", line 357, in disconnect raise Error(Error.NOT_CONNECTED, 'Not connected') Error: Not connected (- I know that the brick connected to the Pi is working - the sensors are in regular use and I can connect with the brick viewer. Even if I explicitly set the IP address (or choose other bricks on my network) I get the same result. It seems to make no difference what host I set - same result. It does seem to be the brick connection failing (rather than mosquito) but I don't know why. Any ideas? And a question - I have a number of bricks around the house mostly using the wifi extension. Is it possible to set the proxy up to service them all? Or do I need to run one proxy per brick? Quote Link to comment Share on other sites More sharing options...
borg Posted September 27, 2017 at 12:09 PM Share Posted September 27, 2017 at 12:09 PM So the brickd and mqtt broker are running on the RPi? Is the port of the mqtt broker correct? I mean the host and port that you can configure at the top of this file: https://raw.githubusercontent.com/Tinkerforge/brick-mqtt-proxy/master/brick-mqtt-proxy.py Quote Link to comment Share on other sites More sharing options...
Bottesford Posted October 2, 2017 at 11:28 AM Author Share Posted October 2, 2017 at 11:28 AM Yes both the BrickD and MQTT broker are running on the RPi. Both ports are both on the defaults - 4223 / 1883. I have tried the changing the python proxy file to use the following IP addresses: For Brickd host: localhost, 127.0.0.1, 192.168.2.151 (IP of the RPi), 192.168.2.150 (a different brick on via a wifi extension), 192.168.2.167 (an address that does not exist on the network). All of these make no difference to the error message I get. For MQTT broker: localhost, 127.0.0.1, 192.168.2.151 (IP of the RPi) - the error does not change. If I try 192.168.2.167 (an address that does not exist on the network) I get [Errno 113] No route to host. If I try 192.168.2.150 (the address of a TF brick on via a wifi extension) I get [Errno 111] Connection refused. MQTT broker is tested and working via two terminal windows on the Pi as well as connecting and publishing/receiving from my Windows desktop pc using mqtt-spy application. From the above I would say the MQTT broker part is working ok but the brickd connection is not working - to any of my bricks on my network (I have four). Given the stack trace is showing the IPConnection class I'd say it is definitely the brick connection that is failing. Any ideas? Totally stuck with this now. Quote Link to comment Share on other sites More sharing options...
borg Posted October 2, 2017 at 11:53 AM Share Posted October 2, 2017 at 11:53 AM The backtrace starts in line 1166 with the function "mqtt_on_disconnect". This function is called if mqtt is disconnected. Then the code tries to disconnect the connection to the brickd which gives this "NOT_CONNECTED" exception. Perhaps the mqtt server disconnects the proxy immediately, before the connection to the brickd is established. But why does the mqtt server disconnect immediately? Does it expect some kind of encryption that is not enabled? Quote Link to comment Share on other sites More sharing options...
Bottesford Posted October 3, 2017 at 07:27 AM Author Share Posted October 3, 2017 at 07:27 AM You were correct - it was a problem in the Mosquitto broker. For some reason (that I still don't know) it throws up some weird connection problems that I wasn't able to solve. So I've moved over to using the MQTT broker built into Home Assistant (which is what I'm trying to get working with TF sensors) and now your proxy is working correctly. Thanks for pointing me in the right direction! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.