In my current setup, my MQTT broker is only exposing an MQTTS port(8883). It is using a let's encrypt SSL certificate so using a default SSLSocketFactory is enough for my purpose.
Added new boolean option: dirigera.mqtt.use-ssl. Default is false. If provided, the ssl:// will be used and initialized the default SSL context. Override the dirigera.mqtt.port to point to your MQTTs endpoint, typical port is 8883.
Tested it locally by directly launching the mqtt jar app, see the log message below(redacted some info and to reduce the verbosity):
> java -jar dirigera-client-mqtt.jar --dirigera.hostname=dirigera.local --dirigera.mqtt.hostname=mqtt.local --dirigera.mqtt.port=8883 --logging.level.root=INFO --dirigera.port=8443 --dirigera.mqtt.use-ssl=true
...
2023-04-07 11:56:53.956 INFO 3403 --- [ main] .d.i.d.c.m.DirigeraClientMqttApplication : Starting DirigeraClientMqttApplication v0.0.1-SNAPSHOT using Java 17.0.5 on ...
2023-04-07 11:56:53.958 DEBUG 3403 --- [ main] .d.i.d.c.m.DirigeraClientMqttApplication : Running with Spring Boot v2.7.5, Spring v5.3.23
2023-04-07 11:56:53.958 INFO 3403 --- [ main] .d.i.d.c.m.DirigeraClientMqttApplication : No active profile set, falling back to 1 default profile: "default"
...
2023-04-07 11:56:54.552 INFO 3403 --- [ main] d.d.i.d.client.api.http.TokenStore : Load access token
2023-04-07 11:56:54.859 INFO 3403 --- [ main] d.d.i.d.client.api.http.ClientOAuthApi : Dirigera client name: ...
2023-04-07 11:56:54.879 INFO 3403 --- [oundedElastic-1] d.d.i.dirigera.client.api.WebSocketApi : Start event handler thread: id=30, name=boundedElastic-1
2023-04-07 11:56:55.533 INFO 3403 --- [oundedElastic-2] d.d.i.d.client.api.http.ClientApi : Start ping thread: id=64, name=boundedElastic-2
2023-04-07 11:56:55.633 INFO 3403 --- [ main] .d.i.d.c.m.DirigeraClientMqttApplication : Connect to MQTT broker: host=mqtt.local, port=8883, publisherId=1c6ed993-ba70-4853-bb8d-a9fc3ad3132d_1, reconnect=true, timeout=0, useSsl=true
2023-04-07 11:56:56.136 INFO 3403 --- [ main] .d.i.d.c.m.DirigeraClientMqttApplication : Connection to MQTT broker successfully established
2023-04-07 11:56:56.139 INFO 3403 --- [ main] d.d.i.d.client.mqtt.MqttEventHandler : Subscribe HassLightDeviceEventHandler to Dirigera websocket: event=DeviceEvent
2023-04-07 11:56:56.476 DEBUG 3403 --- [ main] d.d.i.d.client.mqtt.MqttEventHandler : Publish to MQTT: topic=homeassistant/light/1c...
2023-04-07 11:56:56.485 DEBUG 3403 --- [ main] d.d.i.d.client.mqtt.MqttEventHandler : Subscribe to MQTT topic: topic=homeassistant/...
2023-04-07 11:56:56.493 DEBUG 3403 --- [ main] d.d.i.d.client.mqtt.MqttEventHandler : Publish to MQTT: topic=homeassistant/light/1c...
2023-04-07 11:56:56.501 DEBUG 3403 --- [ main] d.d.i.d.client.mqtt.MqttEventHandler : Publish to MQTT: topic=homeassistant/light/1c...
2023-04-07 11:56:56.510 DEBUG 3403 --- [ main] d.d.i.d.client.mqtt.MqttEventHandler : Publish to MQTT: topic=homeassistant/light/1c...
2023-04-07 11:56:56.518 DEBUG 3403 --- [ main] d.d.i.d.client.mqtt.MqttEventHandler : Subscribe to MQTT topic: topic=homeassistant/...
2023-04-07 11:56:56.520 DEBUG 3403 --- [ main] d.d.i.d.client.mqtt.MqttEventHandler : Publish to MQTT: topic=homeassistant/light/1c...
2023-04-07 11:56:56.527 DEBUG 3403 --- [ main] d.d.i.d.client.mqtt.MqttEventHandler : Publish to MQTT: topic=homeassistant/light/1c...
2023-04-07 11:56:56.538 INFO 3403 --- [ main] d.d.i.d.client.mqtt.MqttEventHandler : Subscribe HassBlindsDeviceEventHandler to Dirigera websocket: event=DeviceEvent
2023-04-07 11:56:56.561 INFO 3403 --- [ main] d.d.i.d.client.mqtt.MqttEventHandler : Subscribe HassMotionSensorDeviceEventHandler to Dirigera websocket: event=DeviceEvent
2023-04-07 11:56:56.580 INFO 3403 --- [ main] d.d.i.d.client.mqtt.MqttEventHandler : Subscribe HassOutletDeviceEventHandler to Dirigera websocket: event=DeviceEvent
...
In my current setup, my MQTT broker is only exposing an MQTTS port(8883). It is using a let's encrypt SSL certificate so using a default SSLSocketFactory is enough for my purpose.
Added new boolean option:
dirigera.mqtt.use-ssl
. Default isfalse
. If provided, thessl://
will be used and initialized the default SSL context. Override thedirigera.mqtt.port
to point to your MQTTs endpoint, typical port is 8883.Tested it locally by directly launching the mqtt jar app, see the log message below(redacted some info and to reduce the verbosity):