I have OwnTracks running on a Hyper-V Ubuntu Server VM. It’s set up to use MQTT on port 8883 and is encrypted using TLS. The OwnTracks Android app successfully connects to the host on port 8883 and updates location info as expected. I have also confirmed that I can connect to the VM’s mosquito broker from the outside using both MQTT Explorer and Node-Red and see device location updates published by the OwnTracks Android app.
On to the problem: I’m working on an OwnTracks Hubitat app and presence driver. The driver uses Hubitat’s MQTT interface (interfaces.mqtt) but I’m unable to establish a connection using the same credentials used in MQTT Explorer and Node-Red, both of which, allow TLS without specifying CA certificate, client certificate, and a passkey. Unfortunately, this doesn’t appear to be possible with the Hubitat MQTT interface. Per the developer docs, the interface exposes two “connect” methods:
void connect(String broker, String clientId, String username, String password)
void connect(String broker, String clientId, String username, String password, options (name/value pairs))
I’ve unsuccessfully tried connecting using both method signatures as follows:
mqttInt.connect(
"tcp://owntracks.mydomainname.com:8883",
"hubitat",
myusername,
mypassword)
mqttInt.connect(
"tcp://owntracks.mydomainname.com:8883",
"hubitat",
myusername,
mypassword,
tlsVersion: "1.2")
...and for good measure...
mqttInt.connect(
"tcp://owntracks.mydomainname.com:8883",
"hubitat",
myusername,
mypassword,
tlsVersion: "1.2",
privateKey: "",
caCertificate: "",
clientCertificate: "")
mqttInt.connect(
"tcp://owntracks.mydomainname.com:8883",
"hubitat",
myusername,
mypassword,
tlsVersion: "1.2",
privateKey: null,
caCertificate: null,
clientCertificate: null)
In all four cases the connection causes the following exception:
error: initialize caused the following exception: Connection lost (32109) - java.net.SocketException: Connection reset
I'm a bit confused as to why I can connect without certs using MQTT Explorer and Node-Red but not from the Hubitat mqtt interface. Anyone have any suggestions as to what I might be doing wrong or provide any workarounds?