我是 PHP 世界的新手,在连接 MQTT 时遇到问题。
我正在使用 phpMQTT.php 库,并且正在使用 IP 地址连接到 MQTT 代理。我正在尝试发布到 MQTT 代理,在 phpMQTT.php 库文件中出现错误
错误是: stream_socket_client(): 无法连接到 tcp:// 。..* :8083(连接超时)
面临以下代码中的问题:
if ($this->cafile) {
$socketContext = stream_context_create(["ssl" => [
"verify_peer_name" => true,
"cafile" => $this->cafile
]]);
$this->socket = stream_socket_client("tls://" . $this->address . ":" . $this->port, $errno, $errstr, 60, STREAM_CLIENT_CONNECT, $socketContext);
} else {
$this->socket = stream_socket_client("tcp://" . $this->address . ":" . $this->port, $errno, $errstr, 60, STREAM_CLIENT_CONNECT);
}