bluerhinos / phpMQTT

a simple php class to connect/publish/subscribe to a MQTT broker
Other
773 stars 460 forks source link

使用PHP调用MQTT.PHP,连接不上服务器,最后的结果是time out! #68

Closed yeziyuan closed 4 years ago

yeziyuan commented 6 years ago

使用PHP调用MQTT.PHP,连接不上服务器,最后的结果是time out! $client_id = "phpMQTT-publisher"; // make sure this is unique for connecting to sever - you could use uniqid() $server = "xxxxx"; // change if necessary $port = xxxxx; // change if necessary $username = "xxxxx"; // set your username $password = "xxxxx"; $mqtt = new phpMQTT($server, $port, $client_id);

if ($mqtt->connect(true, NULL, $username, $password)) { $mqtt->publish("bluerhinos/phpMQTT/examples/publishtest", "Hello World! at " . date("r"), 0); $mqtt->close(); } else { echo "Time out!\n"; }

parispring commented 6 years ago

看看网络通不通,或者试一下客户端。 maybe network error,or use the client

kingtiwns commented 6 years ago

先看看 相关参数是否正确,下个mqtt.fx测试 ,phpmqtt只支持mqttv3.1,有的mq是3.1.1的需要修改代码

bluerhinos commented 4 years ago

I am restarting this project so having a clear out of old issues (If you believe this is still valid please reopen)