经过测试mosquitto.exe 2.0.20版官方编译版不支持websocket,需要自己编译才支持。或者使用2.0.14版。
原生支持websocket的mqtt server是nanomq,但测试发现总有问题,特别是websocket mqtt的通信总有些莫名其妙的问题。https://nanomq.io
结论
使用mosquitto 2.0.14版本支持websocket for windows
mosquitto.conf文件内容:
listener 1883
listener 9889
protocol websockets
socket_domain ipv4
allow_anonymous true

