-
-
Save ajumalp/0ad2517d15c999cfc440cdf3d623fab8 to your computer and use it in GitHub Desktop.
From https://synocommunity.com add http://packages.synocommunity.com to your NAS package sources. | |
For that, go to NAS->Package Cnter->Click Settings->Package Sources tab. | |
Then from the community, you can see Mosquitto. Install it. | |
After installing, please stop the Mosquitto service before updating configuration. You can start service after changes. | |
Enable Admin login for Synology | |
Enable SSH in NAS | |
Download putty and connect to NAS Server | |
Login using admin | |
Change to root user [sudo -i, {use admin password}] | |
Find mosquitto.conf file [find / -name mosquitto.conf] | |
Go to that path using cd [in my case cd /volume1/@appstore/mosquitto/var] | |
Edit mosquitto.conf [vi mosquitto.conf] | |
Might say it's used by another process. Force edit. | |
Scroll down and find # allow_anonymous [around line 513] | |
Remove # and make [allow_anonymous false] [Use insert on keyboard to edit] | |
Scroll and find #password_file [around line 555] | |
Remove # and make password_file /volume1/@appstore/mosquitto/var/password_file [where 2nd password_file is the actual filename] | |
Save the file [Esc-> :wq to save] | |
Now create a file password_file in /volume1/@appstore/mosquitto/var/ | |
Ensure your are still in same directory, type vi password_file | |
This will create new file, press insert and type your username and password in below format | |
username:password [Username should not contain :]. You can add multiple users line by line | |
Save file and clseo [Esc->:wq] | |
Find mosquitto_passwd [find / -name mosquitto_passwd] | |
Stay in the mosquitto.conf folder itself. Because we have password_file file here. | |
From mosquitto.conf folder, type mosquitto_passwd [along with path] -U password_file to encrypt password. | |
In my case /volume1/@appstore/mosquitto/bin/mosquitto_passwd -U password_file | |
Start/restart Mosquitto Server | |
All done. Thank You. |
Hi all,
I'm very happy to know this was helpful to you all.
Thank You
I've published a code to Automate Home and Office here
Smart Home
Get the source code here
A web based complete source code for Home Automation including ESP8266 firmware.
This application helps to control electronic devices remotely. This can be installed in your local network, and because you all have Synology NAS Server you can access your devices from any where. You need a WiFi/Ethernet at Home/Office to connect Arduino devices. Then from your phone, you can control connected appliances
- This support PWA [Progressive Web App]. So this can be easily installed into any OS supporting PWA
- The Arduino code for the devices is also included in the Hardware folder
- Mainly supporting ESP8266 devices
- Mainly developed for Synology NAS Server [tested in DS218+]
This instruction was very helpful for me, thanks @ajumalp!
Many thanks for these instructions. The find functionality didnt work for me but I didn't needit. More importantly I cound encrypt my password as I got errors that my password file was corrupt. The workaround I found was to let the mosquitto_paswd tool add the username and password (immediately encrypted) into the password file. This is the command:
/volume1/@appstore/mosquitto/bin/mosquitto_passwd -c password_file addyourusernamehere
It will then prompt you for the desired password twice
Thanks for the sharing @ajumalp !
I updated (April 7th 2021) in french here : https://lofurol.fr/joomla/electronique/domotique/279-nas-syno-installation-du-broker-mosquitto-mqtt
Regards
Hi, thanks for sharing.
I followed through and set it up with no errors.
However, when connecting with any client, it's connecting with any name/password. It's like if 'allow_anonymous false' has no effect.
Listing the files, I noticed a differance in users between the password file and conf. Could that be the problem?
TIA
$ ls -la
total 56
drwxr-xr-x 2 sc-mosquitto sc-mosquitto 4096 Sep 27 12:33 .
drwxr-xr-x 9 sc-mosquitto sc-mosquitto 4096 Aug 11 00:08 ..
-rw-r--r-- 1 sc-mosquitto sc-mosquitto 44637 Sep 27 01:48 mosquitto.conf
-rw-r--r-- 1 root root 116 Sep 27 12:33 pwd_file
EDIT:
I changed the owner/groupship for file pwd_file with no avail. Of course, did stop/run the server.
I followed through and set it up with no errors. However, when connecting with any client, it's connecting with any name/password. It's like if 'allow_anonymous false' has no effect. Listing the files, I noticed a differance in users between the password file and conf. Could that be the problem? TIA
Face similar case on my DSM 7.0.1. Make sure you edit config file
from /volume1/@appdata/mosquitto/mosquitto.conf
,
not_ /volume1/@appstore/mosquitto/var/mosquitto.conf
.
@dieterplex thank you.
to avoid multiple .conf files I just put one line in /volume1/@appdata/mosquitto/mosquitto.conf: "include_dir /volume1/@appstore/mosquitto/var/" and stayed with /volume1/@appstore/mosquitto/var/mosquitto.conf
to avoid multiple .conf files I just put one line in /volume1/@appdata/mosquitto/mosquitto.conf: "include_dir /volume1/@appstore/mosquitto/var/" and stayed with /volume1/@appstore/mosquitto/var/mosquitto.conf
did you delete everything else in that file? Or just added it somewhere
Don't forget to chown sc-mosquitto:sc-mosquitto pw_file
Thank you all to all for the helpful snippets and hints.
I am a noob when it comes to mosquitto and shell configuration files.
My pitfall was definitely the configuration of the IP address and port on the listener.
In my case, mosquitto.conf said
listener 1883 127.0.0.1
and I had no access without an error message in the log.
After I entered the IP address of my NAS there, it worked.
Good morning the code no longer works, it is impossible to connect to the mqtt the paths are no longer the same the var folder does not exist the @appstore folder is replaced by @appdata
Hey @monfiston
you can find the config under /var/packages/mosquitto/var/
Hey,
doesn't work for me on my DS723+ under DSM 7.2.1
I modified the files /var/packages/mosquitto/var/mosquitto. conf and /var/packages/mosquitto/var/passwd
Encrypted the passwd, open port 1883 on the firewall and start the package.
I have this screen as soon as I click o the Connect button with the error message: Disconnected from server :(
Thank you all to all for the helpful snippets and hints. I am a noob when it comes to mosquitto and shell configuration files. My pitfall was definitely the configuration of the IP address and port on the listener. In my case, mosquitto.conf said
listener 1883 127.0.0.1
and I had no access without an error message in the log. After I entered the IP address of my NAS there, it worked.
This did it for me!
Thanks for the detailed tutorial, my MQTT server is online
thanks