| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211 |
- spring:
- application:
- name: iot-gateway-server
- profiles:
- active: local # 默认激活本地开发环境
- # Redis 配置
- redis:
- host: 127.0.0.1 # 地址
- port: 6379 # 端口
- database: 5 # 数据库索引
- username: default
- password: 123456
- --- #################### 消息队列相关 ####################
- # rocketmq 配置项,对应 RocketMQProperties 配置类
- rocketmq:
- name-server: 127.0.0.1:9876 # RocketMQ Namesrv
- # Producer 配置项
- producer:
- group: ${spring.application.name}_PRODUCER # 生产者分组
- --- #################### IoT 网关相关配置 ####################
- yudao:
- iot:
- # 消息总线配置
- message-bus:
- type: redis # 消息总线的类型
- # 网关配置
- gateway:
- # 设备 RPC 配置
- rpc:
- url: http://127.0.0.1:58080 # 主程序 API 地址
- connect-timeout: 30s
- read-timeout: 30s
- # 设备 Token 配置
- token:
- secret: yudaoIotGatewayTokenSecret123456789 # Token 密钥,至少32位
- expiration: 7d
- # 协议实例列表
- protocols:
- # ====================================
- # 针对引入的 HTTP 组件的配置
- # ====================================
- - id: http-json
- protocol: http
- port: 8092
- enabled: false
- # ====================================
- # 针对引入的 TCP 组件的配置
- # ====================================
- - id: tcp-json
- enabled: false
- protocol: tcp
- port: 8091
- serialize: json
- tcp:
- max-connections: 1000
- keep-alive-timeout-ms: 30000
- codec:
- type: delimiter # 拆包类型:length_field / delimiter / fixed_length
- delimiter: "\\n" # 分隔符(支持转义:\\n=换行, \\r=回车, \\t=制表符)
- # type: length_field # 拆包类型:length_field / delimiter / fixed_length
- # length-field-offset: 0 # 长度字段偏移量
- # length-field-length: 4 # 长度字段长度
- # length-adjustment: 0 # 长度调整值
- # initial-bytes-to-strip: 4 # 初始跳过的字节数
- # type: fixed_length # 拆包类型:length_field / delimiter / fixed_length
- # fixed-length: 256 # 固定长度
- # ====================================
- # 针对引入的 UDP 组件的配置
- # ====================================
- - id: udp-json
- enabled: false
- protocol: udp
- port: 8093
- serialize: json
- udp:
- max-sessions: 1000 # 最大会话数
- session-timeout-ms: 60000 # 会话超时时间(毫秒),基于 Guava Cache 自动过期
- receive-buffer-size: 65536 # 接收缓冲区大小(字节)
- send-buffer-size: 65536 # 发送缓冲区大小(字节)
- # ====================================
- # 针对引入的 WebSocket 组件的配置
- # ====================================
- - id: websocket-json
- enabled: false
- protocol: websocket
- port: 8094
- serialize: json
- websocket:
- path: /ws
- max-message-size: 65536 # 最大消息大小(字节,默认 64KB)
- max-frame-size: 65536 # 最大帧大小(字节,默认 64KB)
- idle-timeout-seconds: 60 # 空闲超时时间(秒,默认 60)
- # ====================================
- # 针对引入的 CoAP 组件的配置
- # ====================================
- - id: coap-json
- enabled: false
- protocol: coap
- port: 5683
- coap:
- max-message-size: 1024 # 最大消息大小(字节)
- ack-timeout-ms: 2000 # ACK 超时时间(毫秒)
- max-retransmit: 4 # 最大重传次数
- # ====================================
- # 针对引入的 MQTT 组件的配置
- # ====================================
- - id: mqtt-json
- enabled: true
- protocol: mqtt
- port: 1883
- serialize: json
- mqtt:
- max-message-size: 8192 # 最大消息大小(字节)
- connect-timeout-seconds: 60 # 连接超时时间(秒)
- # ====================================
- # 针对引入的 EMQX 组件的配置
- # ====================================
- - id: emqx-1
- enabled: false
- protocol: emqx
- port: 8090 # EMQX HTTP Hook 端口(/mqtt/auth、/mqtt/event)
- emqx:
- mqtt-host: 127.0.0.1 # MQTT Broker 地址
- mqtt-port: 1883 # MQTT Broker 端口
- mqtt-username: admin # MQTT 用户名
- mqtt-password: public # MQTT 密码
- mqtt-client-id: iot-gateway-mqtt # MQTT 客户端 ID
- mqtt-ssl: false # 是否开启 SSL
- mqtt-topics:
- - "/sys/#" # 系统主题
- mqtt-qos: 1 # 默认 QoS
- clean-session: true # 是否启用 Clean Session (默认: true)
- keep-alive-interval-seconds: 60 # 心跳间隔,单位秒 (默认: 60)
- max-inflight-queue: 10000 # 最大飞行消息队列,单位:条
- connect-timeout-seconds: 10 # 连接超时,单位:秒
- reconnect-delay-ms: 5000 # 重连延迟,单位:毫秒
- # 是否信任所有 SSL 证书 (默认: false)。警告:生产环境必须为 false!
- # 仅在开发环境或内网测试时,如果使用了自签名证书,可以临时设置为 true
- trust-all: true # 在 dev 环境可以设为 true
- # EMQX HTTP Hook 回调网关的 HTTPS 配置(可选)
- http:
- ssl-enabled: false
- # ssl-cert-path: "path/to/server.crt"
- # ssl-key-path: "path/to/server.key"
- # 遗嘱消息配置 (用于网关异常下线时通知其他系统)
- will:
- enabled: true # 生产环境强烈建议开启
- topic: "gateway/status/iot-gateway-mqtt" # 遗嘱消息主题
- payload: "offline" # 遗嘱消息负载
- qos: 1 # 遗嘱消息 QoS
- retain: true # 遗嘱消息是否保留
- # 高级 SSL/TLS 配置 (当 trust-all: false 且 mqtt-ssl: true 时生效)
- ssl-options:
- key-store-path: "classpath:certs/client.jks" # 客户端证书库路径
- key-store-password: "your-keystore-password" # 客户端证书库密码
- trust-store-path: "classpath:certs/trust.jks" # 信任的 CA 证书库路径
- trust-store-password: "your-truststore-password" # 信任的 CA 证书库密码
- # ====================================
- # 针对引入的 Modbus TCP Client 组件的配置
- # ====================================
- - id: modbus-tcp-client-1
- enabled: false
- protocol: modbus_tcp_client
- port: 502
- modbus-tcp-client:
- config-refresh-interval: 30 # 配置刷新间隔(秒)
- # ====================================
- # 针对引入的 Modbus TCP Server 组件的配置
- # ====================================
- - id: modbus-tcp-server-1
- enabled: false
- protocol: modbus_tcp_server
- port: 503
- modbus-tcp-server:
- config-refresh-interval: 30 # 配置刷新间隔(秒)
- custom-function-code: 65 # 自定义功能码(用于认证等扩展交互)
- request-timeout: 5000 # Pending Request 超时时间(毫秒)
- request-cleanup-interval: 10000 # Pending Request 清理间隔(毫秒)
- --- #################### 日志相关配置 ####################
- # 基础日志配置
- logging:
- file:
- name: iot/logs/${spring.application.name}.log # 日志文件名,全路径
- level:
- # 应用基础日志级别
- cn.iocoder.yudao.module.iot.gateway: ERROR
- org.springframework.boot: ERROR
- # RocketMQ 日志
- org.apache.rocketmq: WARN
- # MQTT 客户端日志
- # io.vertx.mqtt: DEBUG
- # 开发环境详细日志
- cn.iocoder.yudao.module.iot.gateway.protocol.emqx: INFO
- cn.iocoder.yudao.module.iot.gateway.protocol.http: INFO
- cn.iocoder.yudao.module.iot.gateway.protocol.mqtt: ERROR
- cn.iocoder.yudao.module.iot.gateway.protocol.coap: ERROR
- cn.iocoder.yudao.module.iot.gateway.protocol.websocket: ERROR
- cn.iocoder.yudao.module.iot.gateway.protocol.modbus: ERROR
- # 根日志级别
- root: ERROR
- debug: false
|