mqtt.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * This file is part of Hyperf.
  5. *
  6. * @link https://www.hyperf.io
  7. * @document https://hyperf.wiki
  8. * @contact group@hyperf.io
  9. * @license https://github.com/hyperf/hyperf/blob/master/LICENSE
  10. */
  11. use function Hyperf\Support\env;
  12. return [
  13. 'client' => [
  14. 'host' => env('MQTT_CLIENT_HOST', '127.0.0.1'),
  15. 'port' => (int)env('MQTT_CLIENT_PORT', 1883),
  16. 'pool' => [
  17. 'userName' => env('MQTT_CLIENT_USERNAME', ''),
  18. 'password' => env('MQTT_CLIENT_PASSWORD', ''),
  19. 'clientId' => env('MQTT_CLIENT_CLIENT_ID', 'hyperf'), // 客户端id
  20. 'keepAlive' => 60, // 心跳 默认0秒,设置成0代表禁用
  21. 'protocolName' => 'MQTT', // 协议名,默认为MQTT(3.1.1版本),也可为MQIsdp(3.1版本)
  22. 'protocolLevel' => 4, // 协议等级,MQTT3.1.1版本为4,5.0版本为5,MQIsdp为3
  23. 'properties' => [], // MQTT5 中所需要的属性
  24. 'delay' => 3000, // 重连时的延迟时间 (毫秒)
  25. 'maxAttempts' => 5, // 最大重连次数。默认-1,表示不限制
  26. 'swooleConfig' => [
  27. 'open_mqtt_protocol' => true,
  28. 'package_max_length' => 2 * 1024 * 1024
  29. ]
  30. ],
  31. ],
  32. ];