application.yaml 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. spring:
  2. application:
  3. name: iot-gateway-server
  4. profiles:
  5. active: local # 默认激活本地开发环境
  6. # Redis 配置
  7. redis:
  8. host: 127.0.0.1 # 地址
  9. port: 6379 # 端口
  10. database: 5 # 数据库索引
  11. username: default
  12. password: 123456
  13. --- #################### 消息队列相关 ####################
  14. # rocketmq 配置项,对应 RocketMQProperties 配置类
  15. rocketmq:
  16. name-server: 127.0.0.1:9876 # RocketMQ Namesrv
  17. # Producer 配置项
  18. producer:
  19. group: ${spring.application.name}_PRODUCER # 生产者分组
  20. --- #################### IoT 网关相关配置 ####################
  21. yudao:
  22. iot:
  23. # 消息总线配置
  24. message-bus:
  25. type: redis # 消息总线的类型
  26. # 网关配置
  27. gateway:
  28. # 设备 RPC 配置
  29. rpc:
  30. url: http://127.0.0.1:58080 # 主程序 API 地址
  31. connect-timeout: 30s
  32. read-timeout: 30s
  33. # 设备 Token 配置
  34. token:
  35. secret: yudaoIotGatewayTokenSecret123456789 # Token 密钥,至少32位
  36. expiration: 7d
  37. # 协议实例列表
  38. protocols:
  39. # ====================================
  40. # 针对引入的 HTTP 组件的配置
  41. # ====================================
  42. - id: http-json
  43. protocol: http
  44. port: 8092
  45. enabled: false
  46. # ====================================
  47. # 针对引入的 TCP 组件的配置
  48. # ====================================
  49. - id: tcp-json
  50. enabled: false
  51. protocol: tcp
  52. port: 8091
  53. serialize: json
  54. tcp:
  55. max-connections: 1000
  56. keep-alive-timeout-ms: 30000
  57. codec:
  58. type: delimiter # 拆包类型:length_field / delimiter / fixed_length
  59. delimiter: "\\n" # 分隔符(支持转义:\\n=换行, \\r=回车, \\t=制表符)
  60. # type: length_field # 拆包类型:length_field / delimiter / fixed_length
  61. # length-field-offset: 0 # 长度字段偏移量
  62. # length-field-length: 4 # 长度字段长度
  63. # length-adjustment: 0 # 长度调整值
  64. # initial-bytes-to-strip: 4 # 初始跳过的字节数
  65. # type: fixed_length # 拆包类型:length_field / delimiter / fixed_length
  66. # fixed-length: 256 # 固定长度
  67. # ====================================
  68. # 针对引入的 UDP 组件的配置
  69. # ====================================
  70. - id: udp-json
  71. enabled: false
  72. protocol: udp
  73. port: 8093
  74. serialize: json
  75. udp:
  76. max-sessions: 1000 # 最大会话数
  77. session-timeout-ms: 60000 # 会话超时时间(毫秒),基于 Guava Cache 自动过期
  78. receive-buffer-size: 65536 # 接收缓冲区大小(字节)
  79. send-buffer-size: 65536 # 发送缓冲区大小(字节)
  80. # ====================================
  81. # 针对引入的 WebSocket 组件的配置
  82. # ====================================
  83. - id: websocket-json
  84. enabled: false
  85. protocol: websocket
  86. port: 8094
  87. serialize: json
  88. websocket:
  89. path: /ws
  90. max-message-size: 65536 # 最大消息大小(字节,默认 64KB)
  91. max-frame-size: 65536 # 最大帧大小(字节,默认 64KB)
  92. idle-timeout-seconds: 60 # 空闲超时时间(秒,默认 60)
  93. # ====================================
  94. # 针对引入的 CoAP 组件的配置
  95. # ====================================
  96. - id: coap-json
  97. enabled: false
  98. protocol: coap
  99. port: 5683
  100. coap:
  101. max-message-size: 1024 # 最大消息大小(字节)
  102. ack-timeout-ms: 2000 # ACK 超时时间(毫秒)
  103. max-retransmit: 4 # 最大重传次数
  104. # ====================================
  105. # 针对引入的 MQTT 组件的配置
  106. # ====================================
  107. - id: mqtt-json
  108. enabled: true
  109. protocol: mqtt
  110. port: 1883
  111. serialize: json
  112. mqtt:
  113. max-message-size: 8192 # 最大消息大小(字节)
  114. connect-timeout-seconds: 60 # 连接超时时间(秒)
  115. # ====================================
  116. # 针对引入的 EMQX 组件的配置
  117. # ====================================
  118. - id: emqx-1
  119. enabled: false
  120. protocol: emqx
  121. port: 8090 # EMQX HTTP Hook 端口(/mqtt/auth、/mqtt/event)
  122. emqx:
  123. mqtt-host: 127.0.0.1 # MQTT Broker 地址
  124. mqtt-port: 1883 # MQTT Broker 端口
  125. mqtt-username: admin # MQTT 用户名
  126. mqtt-password: public # MQTT 密码
  127. mqtt-client-id: iot-gateway-mqtt # MQTT 客户端 ID
  128. mqtt-ssl: false # 是否开启 SSL
  129. mqtt-topics:
  130. - "/sys/#" # 系统主题
  131. mqtt-qos: 1 # 默认 QoS
  132. clean-session: true # 是否启用 Clean Session (默认: true)
  133. keep-alive-interval-seconds: 60 # 心跳间隔,单位秒 (默认: 60)
  134. max-inflight-queue: 10000 # 最大飞行消息队列,单位:条
  135. connect-timeout-seconds: 10 # 连接超时,单位:秒
  136. reconnect-delay-ms: 5000 # 重连延迟,单位:毫秒
  137. # 是否信任所有 SSL 证书 (默认: false)。警告:生产环境必须为 false!
  138. # 仅在开发环境或内网测试时,如果使用了自签名证书,可以临时设置为 true
  139. trust-all: true # 在 dev 环境可以设为 true
  140. # EMQX HTTP Hook 回调网关的 HTTPS 配置(可选)
  141. http:
  142. ssl-enabled: false
  143. # ssl-cert-path: "path/to/server.crt"
  144. # ssl-key-path: "path/to/server.key"
  145. # 遗嘱消息配置 (用于网关异常下线时通知其他系统)
  146. will:
  147. enabled: true # 生产环境强烈建议开启
  148. topic: "gateway/status/iot-gateway-mqtt" # 遗嘱消息主题
  149. payload: "offline" # 遗嘱消息负载
  150. qos: 1 # 遗嘱消息 QoS
  151. retain: true # 遗嘱消息是否保留
  152. # 高级 SSL/TLS 配置 (当 trust-all: false 且 mqtt-ssl: true 时生效)
  153. ssl-options:
  154. key-store-path: "classpath:certs/client.jks" # 客户端证书库路径
  155. key-store-password: "your-keystore-password" # 客户端证书库密码
  156. trust-store-path: "classpath:certs/trust.jks" # 信任的 CA 证书库路径
  157. trust-store-password: "your-truststore-password" # 信任的 CA 证书库密码
  158. # ====================================
  159. # 针对引入的 Modbus TCP Client 组件的配置
  160. # ====================================
  161. - id: modbus-tcp-client-1
  162. enabled: false
  163. protocol: modbus_tcp_client
  164. port: 502
  165. modbus-tcp-client:
  166. config-refresh-interval: 30 # 配置刷新间隔(秒)
  167. # ====================================
  168. # 针对引入的 Modbus TCP Server 组件的配置
  169. # ====================================
  170. - id: modbus-tcp-server-1
  171. enabled: false
  172. protocol: modbus_tcp_server
  173. port: 503
  174. modbus-tcp-server:
  175. config-refresh-interval: 30 # 配置刷新间隔(秒)
  176. custom-function-code: 65 # 自定义功能码(用于认证等扩展交互)
  177. request-timeout: 5000 # Pending Request 超时时间(毫秒)
  178. request-cleanup-interval: 10000 # Pending Request 清理间隔(毫秒)
  179. --- #################### 日志相关配置 ####################
  180. # 基础日志配置
  181. logging:
  182. file:
  183. name: iot/logs/${spring.application.name}.log # 日志文件名,全路径
  184. level:
  185. # 应用基础日志级别
  186. cn.iocoder.yudao.module.iot.gateway: ERROR
  187. org.springframework.boot: ERROR
  188. # RocketMQ 日志
  189. org.apache.rocketmq: WARN
  190. # MQTT 客户端日志
  191. # io.vertx.mqtt: DEBUG
  192. # 开发环境详细日志
  193. cn.iocoder.yudao.module.iot.gateway.protocol.emqx: INFO
  194. cn.iocoder.yudao.module.iot.gateway.protocol.http: INFO
  195. cn.iocoder.yudao.module.iot.gateway.protocol.mqtt: ERROR
  196. cn.iocoder.yudao.module.iot.gateway.protocol.coap: ERROR
  197. cn.iocoder.yudao.module.iot.gateway.protocol.websocket: ERROR
  198. cn.iocoder.yudao.module.iot.gateway.protocol.modbus: ERROR
  199. # 根日志级别
  200. root: ERROR
  201. debug: false