var connectOptions = {
host: "192.168.1.76",
port: 8883,
protocol: "mqtts",
keepalive: 10,
clientId: serverUID,
protocolId: "MQTT",
protocolVersion: 4,
clean: true,
reconnectPeriod: 2000,
connectTimeout: 2000,
key: fs.readFileSync("./keys/key.pem"),
cert: fs.readFileSync("./keys/cert.pem"),
rejectUnauthorized: false,
};
var client = mqtt.connect(connectOptions);
{mqtts, 8883, [ %% Size of acceptor pool {acceptors, 16},
%% Maximum number of concurrent clients {max_clients, 512},
%% Socket Access Control {access, [{allow, all}]},
%% SSL certificate and key files {ssl, [{certfile, "etc/ssl/crt.pem"}, {keyfile, "etc/ssl/key.pem"}]},
%% Socket Options {sockopts, [ {backlog, 1024} %{buffer, 4096}, ]} ]}, %% WebSocket over HTTPS Listener {https, 8083, [ %% Size of acceptor pool {acceptors, 4}, %% Maximum number of concurrent clients {max_clients, 512}, %% Socket Access Control {access, [{allow, all}]}, %% SSL certificate and key files {ssl, [{certfile, "etc/ssl/crt.pem"}, {keyfile, "etc/ssl/key.pem"}]}, %% Socket Options {sockopts, [ %{buffer, 4096}, {backlog, 1024} ]} ]}
- mosquitto_pub -h mqtt.example.com -t test -m "hello again" -p 8883 --capath /etc/ssl/certs/ -u "sammy" -P "password"