I've set up a new dev environment with Nginx as reverse proxy using self signed certificates and a Mosquitto MQTT broker.
I have a NestJS backend using MQTT with following configuration:
private readonly connection = mqtt.connectAsync('wss://mqtt-ssl.test.duckdns.org:9001', {
username: 'local',
password: '12345',
clientId: "backend",
rejectUnauthorized: false, //self signed
});
It immediately connects to the Mosquitto broker running in a docker container.
the angular 20 frontend with same configuration fails to connect to the broker:
export const MQTT_SERVICE_OPTIONS: IMqttServiceOptions = {
url: "wss://mqtt-ssl.test.duckdns.org:9001",
username: "local",
password: "12345",
clientId: "frontend",
rejectUnauthorized: false,
};
@NgModule({
imports: [
CommonModule,
MqttModule.forRoot(MQTT_SERVICE_OPTIONS)
]
WebSocket connection to 'wss://mqtt-ssl.test.duckdns.org:9001/' failed:
Is there any additional step required?
I open the frontend via: https://frontend.test.duckdns.org (chrome) and starting it with run config: "ng serve --host 192.168.2.178 --disable-host-check"
I also use MQTTX and I can connect with the same config as I use in the frontend.