Mosquitto (MQTT) and TLS or Pre-Shared Key (PSK)
by Turbocapitalist from LinuxQuestions.org on (#542EB)
I've been having no progress in getting mosquitto to work with a pre-shared key. The log only ever shows "socket error" when I connect with the client:
Code:1590740940: Opening ipv4 listen socket on port 8883.
1590740940: Opening ipv6 listen socket on port 8883.
1590740970: New connection from 192.0.2.196 on port 8883.
1590740970: Socket error on client <unknown>, disconnecting.The mosquitto server secondary configuration file is like this under /etc/mosquitto/conf.d/
Code:port 8883
psk_file /etc/mosquitto/certs/presharedkeyThe main configuration file is left as the default:
Code:pid_file /var/run/mosquitto.pid
persistence true
persistence_location /var/lib/mosquitto/
log_dest file /var/log/mosquitto/mosquitto.log
include_dir /etc/mosquitto/conf.dThe presharedkey file looks like this, using the identity:hexadecimal_key pattern described in the manual page for mosquitto.conf(5)
Code:foo:abcdef0123456789I launch the publishing client like this but it just waits, showing no output.
Code:mosquitto_pub \
-h 192.0.2.251 \
-t "randomtopic" \
-p 8883 \
--psk abcdef0123456789 --psk-identity foo \
-m 'hello'The server (broker) shows the log message above at the top of the post. Apparently I have missed something crucial. What do I need to add or change to avoid the socket error get a proper connection which passes encrypted MQTT messages?


Code:1590740940: Opening ipv4 listen socket on port 8883.
1590740940: Opening ipv6 listen socket on port 8883.
1590740970: New connection from 192.0.2.196 on port 8883.
1590740970: Socket error on client <unknown>, disconnecting.The mosquitto server secondary configuration file is like this under /etc/mosquitto/conf.d/
Code:port 8883
psk_file /etc/mosquitto/certs/presharedkeyThe main configuration file is left as the default:
Code:pid_file /var/run/mosquitto.pid
persistence true
persistence_location /var/lib/mosquitto/
log_dest file /var/log/mosquitto/mosquitto.log
include_dir /etc/mosquitto/conf.dThe presharedkey file looks like this, using the identity:hexadecimal_key pattern described in the manual page for mosquitto.conf(5)
Code:foo:abcdef0123456789I launch the publishing client like this but it just waits, showing no output.
Code:mosquitto_pub \
-h 192.0.2.251 \
-t "randomtopic" \
-p 8883 \
--psk abcdef0123456789 --psk-identity foo \
-m 'hello'The server (broker) shows the log message above at the top of the post. Apparently I have missed something crucial. What do I need to add or change to avoid the socket error get a proper connection which passes encrypted MQTT messages?