mqtt.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * This file is part of Panda.
  5. *
  6. * @link https://www.yangertao.com
  7. * @contact joeyoung0314@qq.com
  8. * @license https://github.com/nashgao/mqtt-client
  9. */
  10. use function Hyperf\Support\env;
  11. return [
  12. 'default' => [
  13. 'host' => env('MQTT_CLIENT_HOST', 'localhost'),
  14. 'port' => env('MQTT_CLIENT_PORT', 1883),
  15. // http port option deprecated
  16. 'http_port' => env('MQTT_CLIENT_HTTP_PORT', 8081),
  17. 'time_out' => env('MQTT_CLIENT_TIMEOUT', 10),
  18. 'keepalive' => env('MQTT_CLIENT_KEEPALIVE', 60),
  19. 'protocol_name' => 'MQTT',
  20. 'protocol_level' => env('MQTT_CLIENT_PROTOCOL_LEVEL', 5),
  21. 'username' => env('MQTT_CLIENT_USERNAME', 'admin'),
  22. 'password' => env('MQTT_CLIENT_PASSWORD', 'public'),
  23. 'clean_session' => false,
  24. 'will' => [], // template: ['topic' => $topic, 'message' => 'bye']
  25. 'properties' => [
  26. ],
  27. 'swoole_config' => [
  28. 'package_max_length' => 1024 * 1024,
  29. 'connect_timeout' => 5.0,
  30. 'keepalive' => 0, // 默认0秒,表示禁用
  31. 'ssl_enabled' => false,
  32. 'ssl_cert_file' => '',
  33. 'ssl_key_file' => '',
  34. 'ssl_cafile' => '',
  35. ],
  36. 'http' => [
  37. 'host' => env('MQTT_CLIENT_HTTP_HOST', 'localhost'),
  38. 'port' => env('MQTT_CLIENT_HTTP_PORT', 8081),
  39. 'app_id' => env('MQTT_CLIENT_HTTP_APP_ID', 'admin'),
  40. 'app_secret' => env('MQTT_CLIENT_HTTP_APP_SECRET', 'public'),
  41. ],
  42. 'pool' => [
  43. 'min_connections' => 1,
  44. 'max_connections' => 10,
  45. 'connect_timeout' => 10.0,
  46. 'wait_timeout' => 20.0,
  47. 'heartbeat' => -1,
  48. 'max_idle_time' => 60,
  49. ],
  50. 'prefix' => env('MQTT_CLIENT_CLIENT_ID', 'hyperf'),// 前缀
  51. 'subscribe' => [
  52. 'topics' => [
  53. [
  54. 'topic' => 'abcd/device/msg',// 主题
  55. 'auto_subscribe' => false, // true 跟随 hyperf 服务器启动 订阅所提到的主题
  56. 'enable_multisub' => false,
  57. 'multisub_num' => 2, // 让多个订阅同一个主题,通常适用于队列主题和共享主题
  58. 'enable_share_topic' => false,
  59. 'share_topic' => [
  60. 'group_name' => [], // 组名列表
  61. ],
  62. 'enable_queue_topic' => false, // 队列主题具有更高的优先级,如果定义了队列主题,那么共享主题将是无用的
  63. 'qos' => 2,
  64. 'filter' => null,
  65. 'no_local' => true,
  66. 'retain_as_published' => true,
  67. 'retain_handling' => 2,
  68. ],
  69. ],
  70. ],
  71. 'publish' => [
  72. 'topics' => [
  73. [
  74. 'topic' => '+/device/msg',
  75. 'qos' => 2,
  76. 'no_local' => true,
  77. 'retain_as_published' => true,
  78. 'retain_handling' => 2,
  79. ],
  80. ],
  81. ],
  82. ],
  83. ];