Blynk+ESP8266+MQTT+Nodered

Okay, I’ve just compared your screenshot of your mosquitto.conf file…

image

with one of my own mosquitto.conf files…

# Place your local configuration in /etc/mosquitto/conf.d/
#
# A full description of the configuration file is at
# /usr/share/doc/mosquitto/examples/mosquitto.conf.gz

pid_file /run/mosquitto/mosquitto.pid

persistence true
persistence_location /var/lib/mosquitto/

log_dest file /var/log/mosquitto/mosquitto.log

include_dir /etc/mosquitto/conf.d

# force Mosquitto to listen on port 1883
listener 1883
allow_anonymous true

I notice that your file has an entry that says per_listener_settingts_true

I’d suggest that you change this to false and save the changes then restart mosquitto, or reboot the Pi and see if this changes the “Starting in local only mode…” message.

Pete.

I changed the per_listener_settings to false, but unfortunately the system is starting in local mode again.

image

Did you create a copy in /conf.d and if so were these changes made to one or both of the config files?

The error message about “address already in use” seems to imply that you might have another Mosquitto instance running. Are you restarting your Ali when you are doing these tests?

Pete.

Now I copied the same conf file to the /conf.d/ folder (I did not yet in the previous reply), including the per_listener_settings changed to false.

I reboot the RPI by the command sudo reboot. After restarting RPI I typed
mosquitto -v and got the output underneath. Now I don’t get anymore the “Adress already in use” message. Can it be because of starting up the Mosquitto program twice?

It is still going in local mode. There has been a change though: Nodered is contacted to Mosquitto after using localhost:1883 again instead of IP adres:1883 (both without security settings), but the Wemos does not get contact with Mosquitto anymore, with or without security data. Is that because Nodered is on the RPI (local) and the Wemos is external? Maybe the contact with Wemos was over the 2nd. Mosquitto connection that is missing now as I got rid of that "Adress already in use"message?

By the way: What do you mean by "Are you restarting your Ali "; what is Ali?

image

I also see the Nodered actions in the “Putty” window of the RPI, that was not before.

I did setup the RPI to start Mosquitto automaticly. Maybe that is the reason 2 sessions were active, or for becoming the message “Adress already in use” after giving the Mosquitto -v command?

And also with MQTT-Explorer I don’t get a connection anymore.

I think that if Mosquitto was installed correctly it should start automatically. Using the mosquitto -v command in that situation would launch another instance, which isn’t what you want.

I’d recommend clearing-out the Mosquitto log file (the path is in the config file) and rebooting your RPI then doing nothing else other than looking at the log file to see what’s happening.

You might find that using Webmin is a useful way to see what processes are running and whether the config files is being picked-up…

Pete.

I tried to install Webmin with the command:

curl -o setup-repos.sh https://raw.githubusercontent.com/webmin/webmin/master/setup-repos.sh
sh setup-repos.sh

but I get this:
image

Am I doing something wrong?
I’m not very experienced on Raspberry Pi commands as you see…

I don’t know as well how to clearup the log file, but opening it results in only lines like following:
image

For this I typed: sudo nano /var/log/mosquitto/mosquitto.log

as this path is in the Mosquitto.conf file:
image

Use:
sudo curl -o setup-repos.sh https://raw.githubusercontent.com/webmin/webmin/master/setup-repos.sh sh setup-repos.sh

the sudo command runs the install script as root.

You can use the Nano editor to cut (CTRL-K) the text then write-out the edited file (CTRL-O) or you can simply delete the file and allow it to be recreated when you re-start Mosquitto

for that you’d use these three command to stop, remove (rm) the file and restart…

sudo service mosquitto stop
sudo rm /var/log/mosquitto/mosquitto.log
sudo service mosquitto start

Pete.

The installation command to get Webmin gives follwing error:
image

I used the 3 commands to cleanup the log file of Mosquitto.
The first (stopping Mosquitto) seems to work well, as well as the 2nd. The log file appears to be deleted:
image

But at the 3rd. command, the sudo service mosquitto start, I get following message:
image

I’m not sure what isntallation command you used.

My crib-sheet for isntalling Webmin is as follows:

To Install Webmin...

sudo nano /etc/apt/sources.list
Add this line at the end:
deb https://download.webmin.com/download/repository sarge contrib
CTRL-X
Y
Enter

wget http://www.webmin.com/jcameron-key.asc
sudo apt-key add jcameron-key.asc

sudo apt update
sudo apt install webmin

Not sure what caused this, but its maybe some issue with your Mosquitto installation.
What happens if you reboot your Pi then go and look at the log file?

BTW, it would be better if you copied and pated text with triple backticks at the beginning and end rather than posting screenshots.

Pete.

I don’t know how to copy text from the Putty SSH screen and paste it into Windows, thats because I’m using screenshots instead of triple backticks…

I think Mosquitto moght not be well installed on the RPI. I tried to install it again with the commands:

sudo apt install -y mosquitto mosquitto-clients
sudo systemctl enable mosquitto.service

(the second line for starting up Mosquitto after rebooting RPI; are these lines correct?)
At the first sight it seems to work well (I don’t get errors), but when I ask for its status with:

sudo systemctl status mosquitto

I get the following:

And when I type:

sudo systemctl restart mosquitto

I get:
image
so there still is something wrong I guess.

Should I have erased the old version first? If so: how should I do that?

Am I right that

mosquitto -v

just shows the used version and is not starting up the Mosquitto program again? Because when I do this I get a screen that Mosquitto is running (and starting as well):


… but this also does not change any of the files in the logging directory.

I managed to install Webmin, but looking at the running processes, there is nothing with “Mosquitto” in it.

Moreover there are still the same (old) log files in the logging directory, but I think there originally was also one file with another (white) picto and that one isn’t there anymore.

Can’t you just highlight the text with your mouse and copy it with CTRL-C ?

In Webmin go to System > Boitup and Shutdown and scroll down to “Mosquitto service” and click the words “Mosquitto Service” (it’s a hyperlink).

Post a screenshot like this…

Pete.

I guess so.

I don’t know.

My crib sheet for installing Mosquitto is…

Mosquitto 2.xx installation…

wget http://repo.mosquitto.org/debian/mosquitto-repo.gpg.key

sudo apt-key add mosquitto-repo.gpg.key

cd /etc/apt/sources.list.d/

sudo wget http://repo.mosquitto.org/debian/mosquitto-buster.list
sudo apt-get update

sudo apt-get install mosquito

mosquitto -v

sudo systemctl enable mosquitto.service

sudo nano /etc/mosquitto/mosquitto.conf

Move to the end of the file using the arrow keys and paste the following two lines:

listener 1883
allow_anonymous true

CTRL-X
Y
Enter

sudo reboot


sudo service mosquitto stop
sudo systemctl stop mosquitto.service
sudo mosquitto_passwd -c /etc/mosquitto/passwd admin
type the required password and re-enter

sudo nano /etc/mosquitto/mosquitto.conf
CTRL-X
Y
Enter

Pete.

Hello Pete,

So I started from scratch again, formatted the sd card from the RPI, installed its OS again, as well as Nodered. Then I installed the Mosquitto broker as you told and everything seems to work well now. I am also able to contact it from other devices. I guess something went wrong in the original installation and could not be set right anymore.

Thank you very much for all of your help!

Greetings Carl.

1 Like

Great, glad you’re up and running.

Let me know if you have any other questions along the way.

Pete.

Hello Pete,

I managed to get the whole thing working a couple of months ago, but now I have a problem. The RPI does not get onto the internet anymore, I guess some file to get on the internet might be damaged. I did not make any backup of the SD card, and especially of all the Nodered flows. I still can see files on the card with my Windows computer (although they do not make sense to me), but I cannot contact the RPI for watching the files with WINSCP anymore since I am not able anymore to establish an SSH connection. Is it possible to repare the SD card (for example by changing some files from another SD where the OS is installed), or make another one and copy the Nodered flow files from the old one?

The files I see on the SD card in Windows Explorer are as follows:








I don’t know which of these are part of Nodered and Mosquitto.

When you connect a monitor to your RPI and boot it up what do you see? Does it launch the desktop?

Pete.