phpMQTT icon indicating copy to clipboard operation
phpMQTT copied to clipboard

TLS & PHP8 composer-patches

Open politsin opened this issue 3 years ago • 1 comments

{
    "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"
            }
        }
   }
}

politsin avatar Jun 08 '21 10:06 politsin

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) {

politsin avatar Aug 24 '21 08:08 politsin