Reputation: 6974
Hello I have installed mosquitto broker on my Raspberry Pi.
I'm trying to activate SSL but when I try to publish a message it returns connection refused
.
My conf is:
# MQTT over TLS/SSL
listener 8883
cafile /etc/mosquitto/certs/ca.crt
certfile /etc/mosquitto/certs/hostname.crt
keyfile /etc/mosquitto/certs/hostnmae.key
tls_version tlsv1.2
# WebSockets over TLS/SSL
listener 9883
#protocol websockets
cafile /etc/mosquitto/certs/ca.crt
certfile /etc/mosquitto/certs/hostname.crt
keyfile /etc/mosquitto/certs/hostname.key
tls_version tlsv1.2
When I try:
mosquitto_pub --cafile /etc/mosquitto/certs/ca.crt -h localhost -t "test" -m "message" -p 8883
it return
Error: Connection refused
without logs.
Upvotes: 0
Views: 4005
Reputation: 7109
"Connection refused" means that nothing is listening on the port you tried to connect to, 9883.
It's possible the Mosquitto just isn't running, or that it's not actually listening on the port (perhaps it didn't read the correct configuration file, or the configuration file correctly).
You can use lsof
to find out what processes are listening on a port, or what ports a process is listening on.
For instance,
lsof -I :9883
will tell you what processes are listening on port 9883. If you don't see any then there's a problem with the Mosquitto server.
lsof -c mosquitto | grep TCP
will show you a what ports Mosquitto is listening on.
ps ax | grep mosquitto
will show you if Mosquitto is actually running.
If Mosquitto is running but port 9883 doesn't show up then it'll need to figure out why it's not picking up your configuration.
If it's not running you'll need to figure out why.
You may need to install lsof
. You can do that with
sudo apt-get install lsof
Upvotes: 3