Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No MQTT messages #2

Open
xorguy opened this issue Aug 23, 2024 · 21 comments
Open

No MQTT messages #2

xorguy opened this issue Aug 23, 2024 · 21 comments
Labels
bug Something isn't working

Comments

@xorguy
Copy link

xorguy commented Aug 23, 2024

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: - MQTT_BROKER=10.0.0.222 - MQTT_PORT=1883 - MQTT_USERNAME=user - MQTT_PASSWORD=password ports: - 5876:5000 logging: driver: "json-file" options: max-file: "5" # number of files or file count max-size: "100m" # file size

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

@starsoccer
Copy link

Having same issue

@terdia
Copy link
Owner

terdia commented Aug 26, 2024

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
Copy link

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
Copy link

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
Copy link
Author

xorguy commented Aug 26, 2024

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
Copy link
Owner

terdia commented Aug 27, 2024

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
Copy link
Owner

terdia commented Aug 27, 2024

screenshot_1

Botton right there is a button

@starsoccer
Copy link

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
Copy link
Owner

terdia commented Aug 27, 2024

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
Copy link

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
Copy link

ChrisB151 commented Aug 27, 2024

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
Copy link

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
Copy link

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
Copy link

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
Copy link

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
Copy link
Author

xorguy commented Aug 27, 2024

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
Copy link
Owner

terdia commented Aug 27, 2024

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:

  • Better handling of MQTT connections with support for v3 and v5
  • Flexible configuration for both development and production environments
  • Improved error handling for non-UTF-8 encoded MQTT messages

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

@terdia terdia added the bug Something isn't working label Aug 27, 2024
@bfellner
Copy link

Just pulled it and it works like a champ!

@painteau
Copy link

Works for me too ! Thanks !

@starsoccer
Copy link

Confirmed working now

@errorscript
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

8 participants