其它语言的mqttclient
https://www.eclipse.org/paho/downloads.php
1.安装phpmqtt
-----------------------
`composer require bluerhinos/phpmqtt`
2.引入并使用
require("phpMQTT.php");
$server ="127.0.0.1"; // change if necessary
$port =8883; // change if necessary
$username =""; // set your username
$password =""; // set your password
$client_id ="phpMQTT-publisher"; // make sure this is unique for connecting to sever - you could use uniqid()
$mqtt =new phpMQTT($server, $port, $client_id, 'cert/ca.crt');
if ($mqtt->connect(true)) {
$mqtt->publish("bluerhinos/phpMQTT/examples/publishtest", "Hello World! at " . date("r"), 0);
$mqtt->close();
}else {
echo "Time out!\n";
}
//如果不能连接上,改一下phpMQTT.php中的参数 83行 verify_peer_name为false