eclipse-mosquitto / mosquitto

Eclipse Mosquitto - An open source MQTT broker
https://mosquitto.org
Other
9.15k stars 2.41k forks source link

Unable to create websockets listener on port 1884 #1541

Open abhion opened 4 years ago

abhion commented 4 years ago

I did a detailed log and got this

1576674012: mosquitto version 1.6.8 starting
1576674012: Config loaded from mosquitto.conf.
1576674012: Opening websockets listen socket on port 1884.
1576674012: libuv support not compiled in
1576674012: Creating Vhost 'default' port 1884, 3 protocols, IPv6 off
1576674012:  Using non-SSL mode
1576674012: ERROR on binding fd 232 to port 1884 (-1 10048)
1576674012: init server failed
1576674012: Failed to create default vhost
1576674012: Error: Unable to create websockets listener on port 1884.
ralight commented 4 years ago

The error 10048 given here indicates that the port 1884 is already in use. Do you have something else running that is using that port?

abhion commented 4 years ago

@ralight

This probably started happening after I enabled ssl mode as instructed here: http://www.steves-internet-guide.com/mosquitto-tls/. I saw that mosquitto.exe was using the port 1884. I restarted mosquitto service and I ran the config again. Now I get

1576718626: mosquitto version 1.6.8 starting 1576718626: Config loaded from mosquitto.conf. 1576718626: Opening websockets listen socket on port 1884. 1576718626: libuv support not compiled in 1576718626: Creating Vhost 'default' port 1884, 3 protocols, IPv6 off 1576718626: Using non-SSL mode 1576718626: Opening ipv6 listen socket on port 1883. 1576718626: Error: Only one usage of each socket address (protocol/network address/port) is normally permitted.

This is how I enabled websockets in the config:

#protocol mqtt port 1883 listener 1884 protocol websockets

abhion commented 4 years ago

@ralight i got it to work by stopping mosquitto in Services.

But in the log i get 1576718626: Using non-SSL mode though i added the path for the keys and certificate.

`# "openssl rehash " each time you add/remove a certificate.

cafile C:\Users\DemoEngineer\Desktop\cert\ca.crt

capath

Path to the PEM encoded server certificate.

certfile C:\Users\DemoEngineer\Desktop\cert\server.crt

Path to the PEM encoded keyfile.

keyfile C:\Users\DemoEngineer\Desktop\cert\server.key`.

Why can't I enable SSL mode?

ralight commented 4 years ago

If you've copied those lines as they are, then the cafile, certfile, and keyfile lines are all commented out. Please try removing the # at the beginning of the line.