Improve error message for MQTT timeout to include host and port details

This commit is contained in:
audioprog 2025-08-30 16:38:36 +02:00
parent 5f44d76bed
commit 2463b342e5
2 changed files with 17 additions and 59 deletions

View file

@ -53,73 +53,28 @@ Alle 2 Sekunden wird ein JSON wie folgt gesendet:
## Autostart
To set up LoudnessSpy to start automatically using systemd on Raspberry Pi OS Lite, you can create a systemd service file. Heres how to do that:
Steps to Create a systemd Service for LoudnessSpy
```bash
sudo apt install tmux
Open a Terminal:
You should already be in the terminal since you're using Raspberry Pi OS Lite.
nano ~/bashrc
```
Create a systemd Service File:
Use the following command to create a new service file:
Am Ende hinzufügen
```bash
sudo nano /etc/systemd/system/loudnessspy.service
if ! tmux has-session -t loudnessspy 2>/dev/null; then
tmux new-session -d -s loudnessspy '~/loudnessspy'
fi
```
Add the Following Content:
In the opened file, add the following lines:
```ini
[Unit]
Description=LoudnessSpy Service
After=network.target
[Service]
ExecStart=/opt/loudnessspy/loudnessspy
Restart=always
User=pi
Environment=DISPLAY=:0
### tmux Pane Control
[Install]
WantedBy=multi-user.target
```
ExecStart: This is the command to start your application.
Restart=always: This ensures that the service restarts if it crashes.
User=pi: Replace pi with the appropriate user if necessary.
```tmux attach```
Save and Exit:
Press CTRL + X, then Y, and hit Enter to save the changes and exit the editor.
Reload systemd to Recognize the New Service:
Run the following command to reload the systemd manager configuration:
```bash
sudo systemctl daemon-reload
```
Enable the Service to Start on Boot:
Use the following command to enable the service:
```bash
sudo systemctl enable loudnessspy.service
```
Start the Service Immediately (optional):
If you want to start the service right away without rebooting, run:
```bash
sudo systemctl start loudnessspy.service
```
Check the Status of the Service:
You can check if the service is running with:
```bash
sudo systemctl status loudnessspy.service
```
Reboot Your Raspberry Pi:
Restart your Raspberry Pi to ensure that the service starts automatically:
```bash
sudo reboot
```
After following these steps, LoudnessSpy should launch automatically when your Raspberry Pi boots up using systemd. If you encounter any issues, check the service status for error messages and ensure that the paths and permissions are correct.
Ctrl b, " Split pane horizontally \
Ctrl b, % Split pane vertically \
Ctrl b, o Next pane
---
Autor: Leonhard Suckau

View file

@ -164,7 +164,10 @@ async fn main() {
match tokio::time::timeout(Duration::from_secs(3), mqtt.publish(&mqtt_config.topic, QoS::AtLeastOnce, false, payload)).await {
Ok(Ok(_)) => println!("Payload gesendet"),
Ok(Err(e)) => eprintln!("Fehler beim Senden an MQTT: {e}"),
Err(_) => eprintln!("Timeout beim Senden an MQTT (keine Verbindung?)"),
Err(_) => eprintln!(
"Timeout beim Senden an MQTT (keine Verbindung zu {}:{})",
mqtt_config.host, mqtt_config.port
),
}
}
println!("Vor dem eventloop.poll()");