|
@@ -3,7 +3,7 @@ require('../vendor/autoload.php');
|
|
|
use \PhpMqtt\Client\MqttClient;
|
|
|
use \PhpMqtt\Client\ConnectionSettings;
|
|
|
use think\facade\Cache;
|
|
|
-// date_default_timezone_set("PRC");
|
|
|
+date_default_timezone_set("PRC");
|
|
|
// date_default_timezone_set("America/Bahia");
|
|
|
// define('HOST', 'r-bp1eebab79320044pd.redis.rds.aliyuncs.com');
|
|
|
// define('PORT', '6379');
|
|
@@ -95,7 +95,7 @@ function loop()
|
|
|
{
|
|
|
$server = '116.62.220.88';
|
|
|
$port = 1883;
|
|
|
- $clientId = 'repeat_mqtt_livestock_develop';
|
|
|
+ $clientId = 'repeat_mqtt_livestock_develop_paigou';
|
|
|
$username = 'rl517';
|
|
|
$password = "rlian2022";
|
|
|
$clean_session = false;
|
|
@@ -169,7 +169,7 @@ function mqttRepeat($topic,$message){
|
|
|
|
|
|
$server = '61.175.203.188';
|
|
|
$port = 10002;
|
|
|
- $clientId = 'repeat_mqtt_livestock_ningbo';
|
|
|
+ $clientId = 'repeat_mqtt_livestock_ningbo_paigou';
|
|
|
$username = 'rltest';
|
|
|
$password = "rlian@24329";
|
|
|
$clean_session = false;
|
|
@@ -188,15 +188,15 @@ function mqttRepeat($topic,$message){
|
|
|
$mqtt2 = new MqttClient($server, $port, $clientId);
|
|
|
|
|
|
$mqtt2->connect($connectionSettings, $clean_session);
|
|
|
- echo 'connect OK'.PHP_EOL;
|
|
|
- echo 'topic:'.$topic.PHP_EOL;
|
|
|
- echo 'message:'.$message.PHP_EOL;
|
|
|
+ echo '['.date('Y-m-d H:i:s').']connect OK'.PHP_EOL;
|
|
|
+ echo '['.date('Y-m-d H:i:s').']topic:'.$topic.PHP_EOL;
|
|
|
+ echo '['.date('Y-m-d H:i:s').']message:'.$message.PHP_EOL;
|
|
|
$res=$mqtt2->publish(
|
|
|
$topic,
|
|
|
$message,
|
|
|
1
|
|
|
);
|
|
|
- echo 'publish end'.PHP_EOL;
|
|
|
+ echo '['.date('Y-m-d H:i:s').']publish end'.PHP_EOL;
|
|
|
$mqtt2->loop(true,true);
|
|
|
$mqtt2->disconnect();
|
|
|
return $res;
|