Jump to content
View in the app

A better way to browse. Learn more.

Tinkerunity

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Geschrieben

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 (-8)

 

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?

Geschrieben
  • Autor

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.

Geschrieben

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?

Geschrieben
  • Autor

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!

Join the conversation

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

Gast
Reply to this topic...

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.