I'm stuck trying to use phpMQTT to publish to a broker.
I have the web script on one server and the MQTT set up on another remote server.
and I've tested it from the command line with things like:
mosquitto_pub -h
mqtt.widgiot.co.uk -t test -m "hello again" -p 8883 --cafile /etc/ssl/certs/ca-bundle.crt -u "[username]" -P "[password]"
and it works great. Message received
But from the phpMQTT I'm just getting this in my error logs:
This is the function that uses mqtt:
public function onUserLoginFailure($response)
{
require("phpMQTT/phpMQTT.php");
$port = 8883;
$username = "[username]";
$password = "[password]";
$client_id = "phpMQTT-publisher";
$cafile = '/etc/ssl/certs/ca-bundle.crt';
$mqtt = new phpMQTT($server, $port, $client_id , $cafile);
if ($mqtt->connect(true, NULL, $username, $password)) {
$mqtt->publish("test", "Hello World! at " . date("r"), 0);
$mqtt->close();
} else {
echo "Time out!\n";
}
}
The username/password details are correct. I'm just not sure about how to reference the $cacert. I've used the same location as in the terminal (which works).
Any ideas what might be the issue? Firewall? How to check where the blockage is coming from? I have root access on both servers (the one with the phpmqtt script and the mqtt broker server).