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.
https://mqtt.simps.io
Apache License 2.0
358 stars 58 forks source link

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

Closed twim32 closed 9 months ago

twim32 commented 9 months ago

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.

sy-records commented 9 months ago

用 client 需要安装 swoole 扩展。