Launching MQTT broker

Unable to get an MQTT broker launched onto fly. Tried following the appkata example from 2020 but it doesn’t seem to work any longer, and I’m not sure what needs to be done to fix it. Following the guide to a tee works until testing stages, where I run mosquitto_sub -L mqtts://<username>:<password>@server.fly.dev/# --cafile certs/rootCA.pem, and get back Error: Protocol error. Anyone successfully deployed a MQTT broker to Fly and wanna share?

Thanks!

I am having same issues. Tried with no SSL as well, different ports to no avail. I also made sure it is listening on all interfaces. Deploying the Dockerfile locally and exposing the ports work just as expected – it seems something is blocking the connection midway.

The relevant fly.toml parts is

  internal_port = 1883
  protocol = "tcp"
  [[services.ports]]
    handlers = []
    port = "1883"

As mentioned, I tried exposing the service port to 10000 as well but it made no difference. Mosquitto logs tell

1671948107: Opening ipv6 listen socket on port 1883.
1671948107: Opening ipv4 listen socket on port 1883.

so it should be listening on both interfaces (0.0.0.0 and ::)

Make sure that you either exclusively use IPv6 (free) or allocate a IPv4 ($2/mo) for the MQTT Fly app: Announcement: Shared Anycast IPv4 - #3 by kurt

Other than that, I’m not sure if something else has fundamentally changed. What’s the error you see?

I’m also having similar issue trying to setup a MQTT broker on fly. Has anyone been able to successfully set it up?

I have the following in my fly.toml

[[services]]
  internal_port = 1883
  protocol = "tcp"

  [services.concurrency]
    hard_limit = 25
    soft_limit = 20

  [[services.ports]]
    handlers = [ ]
    port = "10000"

  [[services.tcp_checks]]
    interval = 10000
    timeout = 2000

[[mounts]]
  source="mosquitto_data"
  destination="/mosquitto/data"

During deploy I get “WARNING The app is not listening on the expected address and will not be reachable by fly-proxy.” and then there is a timeout waiting for the healthchecks to pass. “Health check on port 1883 has failed. Your app is not responding properly. Services exposed on ports [10000] will have intermittent failures until the health check passes.”

I got it working. Was tough though. It helped deleting the app a couple of times. It seems the issue was with the ipadresses that fly created. I kept both.

$ fly ips list
VERSION IP                      TYPE    REGION  CREATED AT
v4      109.105.216.169         public  global  5m25s ago
v6      2a09:8280:1::69:a392    public  global  5m6s ago

and I only added an mqtt listener on ipv4 like this:

listener 1883 0.0.0.0
listener 9001 0.0.0.0

and exposing those in the docker file (don’t know if that was important)

EXPOSE 1883
EXPOSE 9001

and then matching the port from services.ports with the internal_port.
And then there was a party when I saw this in the log (where I enabled verbose logging with -v and this in the mosquitto.conf file: log_type all

New connection from 172.16.160.xxxxxx