phpMQTT
phpMQTT copied to clipboard
TLS & PHP8 composer-patches
{
"require": {
...
"cweagans/composer-patches": "^1.6",
...
"extra": {
"patches": {
"bluerhinos/phpmqtt": {
"TLS": "https://raw.githubusercontent.com/politsin/snipets/master/patch/phpMQTT.patch",
"PHP8": "https://raw.githubusercontent.com/politsin/snipets/master/patch/mqtt-php8.patch"
}
}
}
}
TLS support
diff --git a/phpMQTT.php b/phpMQTT.php
index 92b65c6..6ebddeb 100644
--- a/phpMQTT.php
+++ b/phpMQTT.php
@@ -147,7 +147,7 @@ class phpMQTT
);
$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);
+ $this->socket = stream_socket_client('tls://' . $this->address . ':' . $this->port, $errno, $errstr, 60, STREAM_CLIENT_CONNECT);
}
if (!$this->socket) {