simps / mqtt

🕹 MQTT Protocol Analysis and Coroutine Client for PHP. Support for 3.1, 3.1.1 and 5.0 versions of the MQTT protocol.

Home Page:https://mqtt.simps.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[BUG] Undefined constant "Simps\MQTT\Config\SWOOLE_SOCK_TCP"

twim32 opened this issue · comments

Execute the command and paste the result below.

Command: php -v && php --ri swoole

PHP 8.3.1 (cli) (built: Dec 21 2023 20:12:13) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.3.1, Copyright (c) Zend Technologies
    with Zend OPcache v8.3.1, Copyright (c), by Zend Technologies
Extension 'swoole' not present.

Description:

$config = new Simps\MQTT\Config\ClientConfig([
    'userName' => $username,
    'password' => $pwd,
    'clientId' => 'iakov',
    'keepAlive' => 10,
    'protocolName' => 'MQTT', // or MQIsdp
    'protocolLevel' => 5, // or 3, 5
    'properties' => [], // optional in MQTT5
    'delay' => 3000, // 3s
    'maxAttempts' => 5,
    'swooleConfig' => []
]);
$client = new \Simps\MQTT\Client($server, $port, $config, \Simps\MQTT\Client::COROUTINE_CLIENT_TYPE);
$client->connect();

Reproducible codes:

# Paste your code here.

You can also provide tcpdump's packet capture logs, Use a command like this: tcpdump -i en0 port 1883 -w mqtt.pcap, Please give me the mqtt.pcap file.
Also remember to change to your network card and port.

用 client 需要安装 swoole 扩展。