Connect MQTT on boot

Hi,
When using MQTT, Repetier Server doesn't automatically connect MQTT on boot.

I have to go to "Global Settings -> MQTT -> Save" to get it to connect and use it.

On Raspberry, I have Mosquitto installed and MQTT service configured to start on boot.

MQTT on Raspberry works always when using the terminal.

MQTT through Repetier Server commands only works when I manually connect it on Global Settings.

Could you point me in the right direction to enable Repetier to connect MQTT on boot?

Please tell me if you need any extra information.

Best regards,
ITFAB.

Comments

  • Do you get in global settings->MQTT a error message like:
    Connection failed: MQTT error [135]: CONNACK return code

    which means MQTT was not reachable at time of startup. During my test I started disconnected and it disappeared once MQTT became active.

    Save is not needed I think. Just use the active button at the top. I think that it just works because save stops and restarts connection. And here I think mqtt is not running at startup or in a condition that triggers issues when server tries to connect, also I can not say which exactly since it works in my case at least.

    Also check server.log to see if server had issues with connecting.

    Also mybe tell me how you connect (tls, verify certificate, mqtt version) in case it depends on mqtt version. I test it with mosquito on homeassistant installation using MQTT 5.
  • In global settings-> MQTT it just says "MQTT - Disconnected". No error messages.

    My server.log when I reboot the server is:
    2023-06-13 12:22:17: MQTT connection lost 
    2023-06-13 12:22:17: Websocket: Client closed connection unexpectedly
    2023-06-13 12:22:19: Stopping for signal 15
    2023-06-13 12:22:19: Stopping printer threads.
    2023-06-13 12:22:19: error: Reading closed serial conection failed: Operation canceled
    2023-06-13 12:22:19: Port closed for ITMAX
    2023-06-13 12:22:19: Connection closed: ITMAX
    2023-06-13 12:22:19: Printer thread for ITMAX stopped
    2023-06-13 12:22:19: Printjob manager thread for ITMAX stopped.
    2023-06-13 12:22:19: Stopping MQTT subsystem ...
    2023-06-13 12:22:19: Stopping lua runner ...
    2023-06-13 12:22:19: Stopping global cloud ...
    2023-06-13 12:22:19: Stopped wifi watcher.
    2023-06-13 12:22:19: Stopping open threads ...
    2023-06-13 12:22:19: Shutting down web server.
    2023-06-13 12:22:19: Closing server
    2023-06-13 12:22:19: Stopping work dispatcher.
    2023-06-13 12:22:19: Work dispatcher thread stopped.
    2023-06-13 12:22:19: Internal Work dispatcher thread stopped.
    2023-06-13 12:22:19: Waiting for all threads to finish ...
    2023-06-13 12:22:19: Worker threads finsihed.
    2023-06-13 12:22:19: Closing user database.
    2023-06-13 12:22:19: Server is now down.
    2023-06-13 12:22:32: Start logging...
    2023-06-13 12:22:32: Repetier-Server 1.4.9
    2023-06-13 12:22:32: Imported external command Shutdown Server
    2023-06-13 12:22:32: Imported external command Reboot Server
    2023-06-13 12:22:32: Imported allowed execute command shutdown
    2023-06-13 12:22:32: Imported allowed execute command reboot
    2023-06-13 12:22:32: Webdirectory: /usr/local/Repetier-Server/www/
    2023-06-13 12:22:32: Storage directory: /var/lib/Repetier-Server/
    2023-06-13 12:22:32: Configuration file: /usr/local/Repetier-Server/etc/RepetierServer.xml
    2023-06-13 12:22:32: Directory for temporary files: /tmp/
    2023-06-13 12:22:32: Reading firmware data ...
    2023-06-13 12:22:33: Starting Network ...
    2023-06-13 12:22:33: Active features:4095
    2023-06-13 12:22:33: Starting user database ...
    2023-06-13 12:22:33: Reading printer configurations ...
    2023-06-13 12:22:33: Reading printer config /var/lib/Repetier-Server/configs/ITMAX.xml
    2023-06-13 12:22:33: Starting printjob manager thread for ITMAX
    2023-06-13 12:22:33: Starting work dispatcher subsystem ...
    2023-06-13 12:22:33: Importing projects ...
    2023-06-13 12:22:33: Initializing LUA ...
    2023-06-13 12:22:33: Starting wifi watcher ...
    2023-06-13 12:22:33: Register LUA cloud services
    2023-06-13 12:22:33: add G-Code-Renderer
    2023-06-13 12:22:33: LUA initalization finished.
    2023-06-13 12:22:33: Setting up MQTT Client ... 
    2023-06-13 12:22:33: Work dispatcher thread started.
    2023-06-13 12:22:33: Starting printer threads ...
    2023-06-13 12:22:33: Internal work dispatcher thread started.
    2023-06-13 12:22:33: Starting printer thread for ITMAX
    2023-06-13 12:22:34: Using ../../ttyACM0 for port /dev/serial/by-id/usb-STMicroelectronics_MARLIN_FYSETC_S6_CDC_in_FS_Mode_204936553056-if00
    2023-06-13 12:22:34: Connection started: ITMAX
    2023-06-13 12:22:34: Internal reset printer ITMAX
    2023-06-13 12:22:34: Reset printer ITMAX
    2023-06-13 12:22:35: Starting web server ... 
    2023-06-13 12:22:35: Webserver started.
    2023-06-13 12:22:39: New SSID Not Connected

    Finally, I have mosquitto version 1.5.7 which is an MQTT v3.1.1 broker. That's the output of the command mosquitto -h.
  • For me it is also working with 3.1.1 broker setting, see here stopping and restarting MQTT server:

    14:31:14.400: Connection failed: MQTT error [-1]: TCP connect timeout
    14:31:14.400: Connection failed: MQTT error [-1]: TCP connect timeout
    14:32:17.664: MQTT connection started  reason: automatic reconnect

    I noticed you are using older 1.4.9 version and I had some fixes on MQTT for 1.4.10 so please upgrade and see if that makes a difference.
  • You are correct, upgrading to 1.4.10 did the trick.

    Excuse my mistake and thanks a lot for the assistance.
Sign In or Register to comment.