'Connection refused: Identifier rejected with ngx-mqtt and Mosquitto via Websockets
I have a Mosquitto broker running from my console on the ports 1883 with the MQTT protocol as well as a websockets connection on port 9001.
PS C:\Program Files\mosquitto> .\mosquitto.exe -v -c .\mosquitto.conf
1643212564: mosquitto version 2.0.14 starting
1643212564: Config loaded from .\mosquitto.conf.
1643212564: Opening ipv6 listen socket on port 1883.
1643212564: Opening ipv4 listen socket on port 1883.
1643212564: Opening websockets listen socket on port 9001.
1643212564: mosquitto version 2.0.14 running
I can connect to the MQTT port from MQTT Explorer without issue, but not to the websocket endpoint.
The error I receive from my Angular application that uses ngx-mqtt is:
ngx-mqtt.js:108 Error: Connection refused: Identifier rejected
at MqttClient.push../node_modules/
ngx-mqtt/node_modules/mqtt/lib/client.js.MqttClient._handleConnack (client.js:1185:1)
In my mosquitto.conf, I am allowing anonymous connections. I have no idea why the identifier is rejected. I looked into the module and they are created normally.
The mosquitto.conf file contains the following:
listener 1883
listener 9001
protocol websockets
allow_anonymous true
From the broker side, the clients appear to connect and immediately disconnect:
1643212911: New client connected from ::1:59092 as client-99c48hibcas (p2, c1, k0, u'guest').
1643212911: No will message specified.
1643212911: Sending CONNACK to client-99c48hibcas (0, 2)
1643212911: Client client-99c48hibcas closed its connection.
I have no idea why this does not work. I cannot connect to the websocket endpoint via Angular's ngx-mqtt or MQTT explorer. Thanks for any suggestions.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
