Running MQTT server with Docker emoncms

Hi,

I’ve recently started to use Emoncms and chose to run an instance in Docker as an easy way to start a project.
But I can’t seem to be able to run MQTT within the container even though the MQTT_ENABLED variable is enabled.

No one seem to be watching the emoncms-docker repo anymore.

In theory there should be single docker container for the MQTT server, on top of the web, db and redis container.

Is anyone running MQTT in a docker container?

I have no idea if the docker install has the Mosquito Broker installed as part of it.

So that doesn’t run the Mosquito Broker, just enables Emoncms to talk to any broker.

On the Emoncms Admin page, what services are running (if that works in a docker).

Your problem might be the MQTT configuration in the settings.ini file for Emoncms.

So that doesn’t run the Mosquito Broker, just enables Emoncms to talk to any broker.
Excellent idea, that would probably be the easiest, and they provide a docker image.
But any tips on how you configure Emoncms to talk to a broker?

On the Emoncms Admin page, what services are running (if that works in a docker).
Emoncms admin page says:

MQTT Server
Version
    Mosquitto ?
Host
    localhost:1883 (127.0.0.1) 

but no process is listening on the port 1883.

And obviously in a Docker container, you have only one process running, and in this case it’s Apache.

Only obvious if you use Docker! Personally, I use PVE containers.

Apologies, it just wasn’t clear to me that MQTT_ENABLED did not mean activating a broker within emoncms.
I just took for granted.

Reading again your message it suddently, and finally!, struck me as evident.
Sorry for my seemingly off-topic messages, it came from the original misunderstanding.

Thanks for your answers.

2 Likes

Actually MQTT_ENABLED is probably meant to start a local MQTT broker.
AFAIU to use an external broker, another service has to be started: emoncms/mqtt_input at master · emoncms/emoncms · GitHub

Which is as problematic in Docker as to run the broker itself.

I still don’t see a way to get this working in Docker, short of rewriting the docker file or compose…

Help still welcome!

No, I don’t think it does.

Looking at this search result Search · MQTT_ENABLED · GitHub and then

The setting controls the running of the PHP MQTT input script. Doesn’t affect the Mosquitto MQTT Broker service that ‘normal’ emoncms setups have.

Your solution is probably to run a second docker image with the MQTT Broker or use the HTTP API.

I run an independent Broker on my setup.

I see.
It makes sense to me.

I now have a container with Mosquitto up and running.

But as far as I understand the issue is still basically the same: PHP MQTT input script is a service that needs to be started.

But the docker container starting Emoncms starts an Apache server service, and hence cannot start the MQTT Input as well.

A solution to this issue would be to start another container with MQTT Input service only.
I’m not sure how that could work with the actual Emoncms code base though.

@borpin you must have PHP MQTT input script service up and running somewhere in your setup if you use a container setup. How do you have it up and running along with the Emoncms Apache server?

Not all container systems are equal. I use PVE. Never got on with Docker.

Previous users must have used the HTTP API.

@glyn.hudson - did you not do this originally?