0
votes

I have installed mosquitto i am using paho to connect sserver over websocket. I am getting

WebSocket connection to 'ws://127.0.0.1:9001/mqtt' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED paho.js:977 WebSocket connection to 'ws://127.0.0.1:9001/mqtt' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED

I am trying to download using sudo apt-add-repository ppa:mosquitto-dev/mosquitto-ppa on ubuntu. I didn't find any /etc/mosquitto directory

I think installing this way will start mosquitto automatically because mosquitto_pub & mosquitto_sub is working fine after installing mosquitto.I didn't started it manualy.

But when i do dpkg --listfiles mosquitto it shows dpkg-query: package 'mosquitto' is not installed.

What i am doing wrong and where can i change the config file. I am not able to locate config file.

1
Please update the question with the following: 1) what version of mosquitto are you using, 2) The content of your config file, 3) the console output from the broker when you try and connecthardillb
Assuming you have run apt-get install mosquitto after adding the ppa then you should have a /etc/mosquitto/ directory with a basic config file. The mosquitto_pub/mosquitto_sub commands are held in the mosquitto-clients package and can be installed with out the brokerhardillb
I had the same issue, I installed mosquitto on an odroid sbc and I got it working by connecting using the hostname 'odroid' not 'localhost' or '127.0.0.1' from the website 'ws://odroid:9001'CaptRisky

1 Answers

1
votes

Websockets are not enabled by default, you will need to add it to the config file

Where the config file is will depend on how and on what platform you installed it, but assuming Linux then it will most likely be in /etc/mosquitto/mosquitto.conf but this will only be used if you are starting the broker as a service. If you start it manually you will have to specify the park to the config file with the -c command line option

You will need to add a listener section something like this:

listener 9001
protocol websockets