mosquitto icon indicating copy to clipboard operation
mosquitto copied to clipboard

Can't access using websockets running on Windows

Open cymplecy opened this issue 4 years ago • 6 comments

I think there is a bug in Windows installer in version 2.0.14 when trying to access via websockets

Summary version 1.6.9 and version 2.0.9a work for me but not version 2.0.14

See here for background https://discourse.nodered.org/t/cant-connect-to-local-mqtt-broker-using-websockets/56035/15?u=cymplecy

cymplecy avatar Jan 04 '22 08:01 cymplecy

I can confirm this issue. It affects versions 2.0.12, 2.0.13 & 2.0.14.

WORKAROUND:

  • Add "socket_domain ipv4" to the end of the config

See my stackoverflow post here for more information: https://stackoverflow.com/questions/70643455/mosquitto-no-websocket-connection-since-version-02-0-12#new-answer

Xtensa2C avatar Jan 11 '22 08:01 Xtensa2C

Confirmed with a fresh install of 2.0.14 running under Windows 11. Using a basic configuration (as below) appears to start up successfully (nothing unusual logged) but connection attempts fail (nothing is logged).

allow_anonymous true

listener 9001
protocol websockets

Adding socket_domain ipv4 (full configuration below) resolves the issue. I have not looked into why this helps but can confirm that it does.

allow_anonymous true

listener 9001
protocol websockets
socket_domain ipv4

MattBrittan avatar Jan 11 '22 22:01 MattBrittan

Thanks for finding the workaround Confirm it works for me on 2.0.14

cymplecy avatar Feb 17 '22 06:02 cymplecy

Thanks! This really took me some time to find out and should work by default. Using 2.0.15 and windows 10 with local broker and clients.

himijendrix24 avatar Nov 30 '22 14:11 himijendrix24

Had the same problem with 2.0.15 and Windows 11.
Connection worked with:

socket_domain ipv4

Thank you!

flashpoint90 avatar May 23 '23 08:05 flashpoint90

The issue is still there with this version:

mosquitto version 2.0.18

mosquitto is an MQTT v5.0/v3.1.1/v3.1 broker.

I had to add above to make it work

leonbrag avatar Aug 25 '24 17:08 leonbrag

I'm having the same issue in the version 2.0.20 for mosquitto broker, and i'm using windows 11 but just adding socket_domain line to the conf file didn't worked for me, can someone enlighten me?

alannogueira709 avatar Nov 28 '24 00:11 alannogueira709

can someone enlighten me?

The socket_domain ipv4 neds to be in the relevant listener section (so chucking it just under protocol websockets is probably the right spot). If this does not work please edit your comment, and add the contents of your mosquitto.conf. Please note that I have not looked into why this works (or why websockets does not work by default under windows).

MattBrittan avatar Nov 28 '24 01:11 MattBrittan

My conf file looks like this:

allow_anonymous true

#HTTP listener
listener 1883

#Websocket listener
listener 9001
protocol websockets
socket_domain ipv4

i don't know why i keep getting these error messages

1732788911: Error: Websockets support not available.

1732788911: Error found at C:\Program Files\mosquitto\mosquitto.conf:8.

alannogueira709 avatar Nov 28 '24 10:11 alannogueira709

1732788911: Error: Websockets support not available.

I think this means that the broker isn't compiled with websocket support.

also, I have a vague memory that the socket_domain option is ignored for webosckets due to issues with libwebsockets

Daedaluz avatar Nov 28 '24 10:11 Daedaluz

So i would've to compile it from source with libwebsockets support, right?

alannogueira709 avatar Nov 28 '24 10:11 alannogueira709

yes

Daedaluz avatar Nov 28 '24 11:11 Daedaluz

So i would've to compile it from source with libwebsockets support, right?

See issue #3148, using an earlier version should help.

MattBrittan avatar Nov 28 '24 17:11 MattBrittan