terdia / mqttui

MQTT Web Interface, a lightweight, open-source tool for real-time MQTT visualization!
MIT License
81 stars 1 forks source link

No MQTT messages #2

Open xorguy opened 2 weeks ago

xorguy commented 2 weeks ago

Hi.

I created an ARM64 image and set with docker compose with environmental variables for mqtt host, port and credentials but I got no MQTT messages at all.

My compose: `mqttui: image: xorguy/mqttui_arm64:1.0.0 container_name: mqttui environment:

Do you have any idea why it seems to not connect to my MQTT broker?

starsoccer commented 2 weeks ago

Having same issue

terdia commented 2 weeks ago

I have added more logs and a debug bar, @xorguy can you try with the latest release?

Edit: I tried with below broker and it worked fine.

services:
  mqtt:
    build:
      context: ../mqtt
    container_name: mqttbroker
    restart: always
    ports:
      - "1883:1883"
bfellner commented 2 weeks ago

Same thing here. I pulled the latest docker image but no messages. Not sure of the others but I require a username and password for connection to my broker.

starsoccer commented 2 weeks ago

Can you clarify what you mean by added a debug bar?

I also have a username/password. I dont see any messages or any new debug logs. All I see in the logs is for http requests which I assume is from me loading the website.

xorguy commented 2 weeks ago

I tried with version 1.0.2 with same results and no additional logs at the docker logs others than my connections to the page and I don't see any change at the repo since 1.0.2.

terdia commented 2 weeks ago

Same thing here. I pulled the latest docker image but no messages. Not sure of the others but I require a username and password for connection to my broker.

I have tested this and it should fail if your broker require username and password and you should see that in the debug bar, can you provide more details about your setup?

terdia commented 2 weeks ago

screenshot_1

Botton right there is a button

starsoccer commented 2 weeks ago

Same thing here. I pulled the latest docker image but no messages. Not sure of the others but I require a username and password for connection to my broker.

I have tested this and it should fail if your broker require username and password and you should see that in the debug bar, can you provide more details about your setup?

I realizedI was on the wrong version which would explain why I didnt see the debug button. You should update the readme to either use the latest or use 1.0.2 as the tag.

Anyways even with the debug button I do not see any errors. My mqtt setup is basically the simplest possible. I am running mosquitto broker with a static IP on the default port, with username/password required for authentication. I have multiple other devices connected without any issue.

For sanity sake I also went into the container installed ping and confirmed the container was able to hit the mqtt server as well.

terdia commented 2 weeks ago

Same thing here. I pulled the latest docker image but no messages. Not sure of the others but I require a username and password for connection to my broker.

I have tested this and it should fail if your broker require username and password and you should see that in the debug bar, can you provide more details about your setup?

I realizedI was on the wrong version which would explain why I didnt see the debug button. You should update the readme to either use the latest or use 1.0.2 as the tag.

Anyways even with the debug button I do not see any errors. My mqtt setup is basically the simplest possible. I am running mosquitto broker with a static IP on the default port, with username/password required for authentication. I have multiple other devices connected without any issue.

For sanity sake I also went into the container installed ping and confirmed the container was able to hit the mqtt server as well.

How are you running the app? Are you using Docker Compose? Have you confirmed that the environment variables are set correctly inside the container?

starsoccer commented 2 weeks ago

Same thing here. I pulled the latest docker image but no messages. Not sure of the others but I require a username and password for connection to my broker.

I have tested this and it should fail if your broker require username and password and you should see that in the debug bar, can you provide more details about your setup?

I realizedI was on the wrong version which would explain why I didnt see the debug button. You should update the readme to either use the latest or use 1.0.2 as the tag. Anyways even with the debug button I do not see any errors. My mqtt setup is basically the simplest possible. I am running mosquitto broker with a static IP on the default port, with username/password required for authentication. I have multiple other devices connected without any issue. For sanity sake I also went into the container installed ping and confirmed the container was able to hit the mqtt server as well.

How are you running the app? Are you using Docker Compose? Have you confirmed that the environment variables are set correctly inside the container?

I am using docker and just pulling your existing container on docker hub. And yes just double checked env variables are being set

ChrisB151 commented 2 weeks ago

I have the same issue. Deployed via compose but I see no logging to show it attempting a connection. My MQTT server needs authentication buut even with this commented out in the compose file I see no errors.

Compose:

version: "3.3"
services:
  mqttui:
    image: terdia07/mqttui:v1.0.2
    container_name: mqttui
    expose:
      - 5000
    environment:
      - MQTT_BROKER=mosquitto
      - MQTT_PORT=1883
      #- MQTT_USERNAME=<removed>
      #- MQTT_PASSWORD=<removed>

    networks:
      - proxy_backend
      - mqtt_backend
    restart: unless-stopped

networks:
  proxy_backend:
    external: true
  mqtt_backend:
    external: true

Container logs:

* Serving Flask app 'app.py' (lazy loading)
 * Environment: production
   WARNING: This is a development server. Do not use it in a production deployment.
   Use a production WSGI server instead.
 * Debug mode: off
WARNING:werkzeug: * Running on all addresses.
   WARNING: This is a development server. Do not use it in a production deployment.
INFO:werkzeug: * Running on http://172.18.0.3:5000/ (Press CTRL+C to quit)

Debug bar: image

The interface opens OK, but I do not see anything to suggest an MQTT connection is being attempted. Happy to provide any further info that may help get to the bottom of this.

starbuck93 commented 2 weeks ago

Also seeing this behavior on 1.0.2. Cannot connect to broker with username and password env variables set and no debug messages if I make the password incorrect, for example. I'm running mqttui on unraid with my mosquitto server on a separate Home Assistant OS box.

Pulling image: terdia07/mqttui:v1.0.2
IMAGE ID [v1.0.2]: Pulling from terdia07/mqttui.
Status: Image is up to date for terdia07/mqttui:v1.0.2

TOTAL DATA PULLED: 0 B

Stopping container: mqttui
Successfully stopped container 'mqttui'

Removing container: mqttui
Successfully removed container 'mqttui'

Command execution
docker run
  -d
  --name='mqttui'
  --net='cloudflared'
  -e TZ="America/Chicago"
  -e HOST_OS="Unraid"
  -e HOST_HOSTNAME="Tower"
  -e HOST_CONTAINERNAME="mqttui"
  -e 'MQTT_BROKER'='10.0.0.11'
  -e 'MQTT_PORT'='1883'
  -e 'MQTT_USERNAME'='mqtt'
  -e 'MQTT_PASSWORD'='testing12345'
  -l net.unraid.docker.managed=dockerman
  -p '5000:5000/tcp' 'terdia07/mqttui:v1.0.2'
2c36cc8268b42f5f6e6f882e137b676a6bdc1903caa0b0578101cb5f30ad77c8

The command finished successfully!
painteau commented 2 weeks ago

Hello ! Same issue for me.

I tried on unraid to log my mqttt server on home assistant too.

I tried different things like changing networking type (host, bridge, etc), but same issue.

errorscript commented 2 weeks ago

Hi,

Using MQTT with authentication can be tricky, as you can use the same username/password on multiple connection, if you have different clientIDs. Here I don't see any option to set a clientID separated from the username. It can be why no log on happen.

It can also be version of MQTT protocol, V3 vs V5, it should also be and option to test.

errorscript commented 2 weeks ago

Hi,

After testing, problem seems to be that we don't do in the main code as name = "app" and not "main" because application is started by flask.

So in file app.py, line 147, if I replace: if __name__ == '__main__': by if __name__ == 'app':

My installation works.

Also I replace line 25 with :

mqtt_client = mqtt.Client(client_id='mqttui',
                         transport='tcp',
                         protocol=mqtt.MQTTv311,
                         clean_session=True)

to be sure to be compatible with my broker.

xorguy commented 2 weeks ago

Hi.

I tested the changes commented by @errorscript and I can see that the app connects to my MQTT broker and see the messages but in a given moment I got an error and stopped working.

Error I got: Exception in thread Thread-1: Traceback (most recent call last): File "/usr/local/lib/python3.9/threading.py", line 980, in _bootstrap_inner self.run() File "/usr/local/lib/python3.9/threading.py", line 917, in run self._target(*self._args, **self._kwargs) File "/usr/local/lib/python3.9/site-packages/paho/mqtt/client.py", line 3452, in _thread_main self.loop_forever(retry_first_connection=True) File "/usr/local/lib/python3.9/site-packages/paho/mqtt/client.py", line 1779, in loop_forever rc = self.loop(timeout, max_packets) File "/usr/local/lib/python3.9/site-packages/paho/mqtt/client.py", line 1181, in loop rc = self.loop_read(max_packets) File "/usr/local/lib/python3.9/site-packages/paho/mqtt/client.py", line 1572, in loop_read rc = self._packet_read() File "/usr/local/lib/python3.9/site-packages/paho/mqtt/client.py", line 2310, in _packet_read rc = self._packet_handle() File "/usr/local/lib/python3.9/site-packages/paho/mqtt/client.py", line 2936, in _packet_handle return self._handle_publish() File "/usr/local/lib/python3.9/site-packages/paho/mqtt/client.py", line 3216, in _handle_publish self._handle_on_message(message) File "/usr/local/lib/python3.9/site-packages/paho/mqtt/client.py", line 3444, in _handle_on_message self.on_message(self, self._userdata, message) File "/app/app.py", line 83, in on_message 'payload': msg.payload.decode(), UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte

May this be related that some MQTT messages are encoded images and the app cannot decode it?

Despite being able to see logs, until crashed, at the docker logs I still don't see any Debug button at the bottom right.

terdia commented 2 weeks ago

Hi everyone,

I've released version 1.3.0, which addresses the reported issues with MQTT connections and improves overall configuration flexibility.

Key improvements include:

Please try this latest release and let us know if you still experience any issues. You can pull the new version using: docker pull terdia07/mqttui:v1.3.0

If problems persist, please provide:

  1. Your docker-compose.yml or docker run command
  2. Any error messages or logs
  3. Details about your MQTT broker setup

Screenshots for debug bar when wrong credential is used Screenshot 2024-08-27 at 23 44 14

Screenshot 2024-08-27 at 23 44 30

Successful connection Screenshot 2024-08-27 at 23 48 06

bfellner commented 2 weeks ago

Just pulled it and it works like a champ!

painteau commented 2 weeks ago

Works for me too ! Thanks !

starsoccer commented 2 weeks ago

Confirmed working now

errorscript commented 2 weeks ago

Hi,

Version 1.3.0 work fine for me. Thanks !

Please update the instructions for docker in README.md to point to version 1.3.0