martin-doyle / node-red-contrib-aedes

MQTT broker for Node-RED based on Aedes
MIT License
61 stars 11 forks source link

Working with Docker #16

Open mozzhead164 opened 4 years ago

mozzhead164 commented 4 years ago

Good Evening, @martin-doyle Hope everyone is safe from Corona!

Trying to get 'node-red-contrib-aedes' to work via Docker swarm...

So far I have it working internally within a node-red docker container, as in [MQTT] communication from one flow to another.

I have had to move away from mosquitto MQTT as they have little to no support for clustering machines together as one larger [HA] MQTT broker, and it seems Aedes is more up to this task...

I am trying to connect (externally) via MQTT.fx which is installed on another host machine and i cant get a connection at all. It keeps saying connection refused.

I'm not sure where to start troubleshooting this as i have a connection internally but cant access it from outside of the docker container. I appreciate if not everyone is using docker to deploy this sort of thing but any guidance would be grateful.

More Details about Setup;

Docker Swarm [Cluster] consisting of 8x Raspberry pi 4 (4GB) nodes each with their own SSD managed by a GlusterFS network share

I have a digitalOcean DNS with 'A' Records pointing to my External IP Address e.g - mqtt.example.com

Traefik Proxy - Serving TLS Certs via lets-encrypt and sitting as the Edge router / load-balancer for Docker Services

Ports 80, 443 & 8883 open on Router to above IP Address They are also listed as entryPoints in Docker file config (via Docker Stack Deploy and compose.yml). Therefore ; tcp://mqtt.example.com:8883 -> Traefik -> Nodered -> Aedes tcp://mqtt.example.com:8883 -> Traefik -> Aedes --would be better - but dont know if this is possible due to Aedes being installed via Nodered inside of the container [i.e - sandboxed])

Nodered is set as a 'router' in Traefik coming through port 443 (also port 80 auto-redirects to 443) so http://node.example.com:80/443 -> Nodered service (port 1880)

Aedes Set up inside each Nodered instance on port 8883 But Aedes can't be accessed through either; tcp://mqtt.example.com:8883 or, tcp://node.example.com:8883


What i am unsure about -

Would I have to go through node.example.com in order to reach Aedes, or can i go direct either through for example; mqtt.example.com:8883

Also, does Aedes have 'SNI' support..? I think traefik needs this support to be able to receive TCP traffic through its frontend routers.

Any pointers are gladly appreciated as ive been trying to get this config to work for some time now and feel like im getting nowhere.

If nobody can help would it be possible for someone to let me know how to debug aedes connections through Nodered, as i used to be able to do it through docker using $ docker service logs x_mqtt When i was using mosquitto as my mqtt docker service.

martin-doyle commented 4 years ago

Some thoughts:

  1. If you want to use a standalone MQTT broker think of using Aedes.js directly.
  2. Aedes has a build-in cluster support (if you really need a cluster). You don't need an extra proxy / load balancer. Just check https://github.com/moscajs/aedes/tree/master/examples/clusters.
  3. If you can't get a connection from the outside check your seetings. Do you use a secure connection (TLS)? Try using mqtt:// for the connection.
martin-doyle commented 4 years ago

Please check also the test files. There are examples for accessing the node-red-contrib-aedes broker from an external client.

martin-doyle commented 4 years ago

@mozzhead164: Any news? Any updates?

mozzhead164 commented 4 years ago

Sorry I didnt reply sooner, been busy with a few different things.

I eventually got it to work, I set up another nodered instance inside docker, but set it up with networking in HOST mode. This allows the container to share the IP address of the host (192.168.....) and now it works. Will have to do more troubleshooting in the coming week to get it to work with Traefik Proxy. Thanks for your help.

Just as a side question.... Does Aedes have a limit on the size of the message sent? I am trying to implement OTA over MQTT - (which would obv result in a large message getting passed through the MQTT protocol) ....would it be possible to send a message of say 500KB or more? Thanks again, if this is off-topic let me know and ill direct the question somewhere else!

martin-doyle commented 4 years ago

Thank you for the message. That is good news. As far as I know the MQTT specification sais 65KB for the topic and 256MB for the payload. 500K should be no problem.

martin-doyle commented 4 years ago

@mozzhead164 Can we close the issue?