Blame view

yudao-module-iot/yudao-module-iot-gateway/src/main/resources/application.yaml 8.99 KB
c3485a3f   YunaiV   reactor:【IoT 物联网】...
1
2
3
  spring:
    application:
      name: iot-gateway-server
d7c57f50   haohao   feat:【IoT 物联网】gat...
4
5
    profiles:
      active: local # 默认激活本地开发环境
c3485a3f   YunaiV   reactor:【IoT 物联网】...
6
  
cda59081   haohao   feat:【IoT 物联网】新增 ...
7
8
9
10
11
12
13
14
15
    # Redis 配置
    data:
      redis:
        host: 127.0.0.1 # Redis 服务器地址
        port: 6379 # Redis 服务器端口
        database: 0 # Redis 数据库索引
        # password: # Redis 密码,如果有的话
        timeout: 30000ms # 连接超时时间
  
c3485a3f   YunaiV   reactor:【IoT 物联网】...
16
17
18
19
  --- #################### 消息队列相关 ####################
  
  # rocketmq 配置项,对应 RocketMQProperties 配置类
  rocketmq:
54a08b97   YunaiV   feat:【IoT 物联网】app...
20
    name-server: 127.0.0.1:9876 # RocketMQ Namesrv
c3485a3f   YunaiV   reactor:【IoT 物联网】...
21
22
23
24
    # Producer 配置项
    producer:
      group: ${spring.application.name}_PRODUCER # 生产者分组
  
d7c57f50   haohao   feat:【IoT 物联网】gat...
25
  --- #################### IoT 网关相关配置 ####################
c3485a3f   YunaiV   reactor:【IoT 物联网】...
26
27
28
  
  yudao:
    iot:
54a08b97   YunaiV   feat:【IoT 物联网】app...
29
30
31
32
      # 消息总线配置
      message-bus:
        type: redis # 消息总线的类型
  
c3485a3f   YunaiV   reactor:【IoT 物联网】...
33
34
35
36
      # 网关配置
      gateway:
        # 设备 RPC 配置
        rpc:
54a08b97   YunaiV   feat:【IoT 物联网】app...
37
          url: http://127.0.0.1:48080 # 主程序 API 地址
c3485a3f   YunaiV   reactor:【IoT 物联网】...
38
39
          connect-timeout: 30s
          read-timeout: 30s
643cc4cf   YunaiV   feat:【IoT 物联网】增加网...
40
41
        # 设备 Token 配置
        token:
54a08b97   YunaiV   feat:【IoT 物联网】app...
42
          secret: yudaoIotGatewayTokenSecret123456789 # Token 密钥,至少32位
643cc4cf   YunaiV   feat:【IoT 物联网】增加网...
43
          expiration: 7d
c3485a3f   YunaiV   reactor:【IoT 物联网】...
44
  
44b1950e   YunaiV   feat(iot):【协议改造】t...
45
        # 协议实例列表
e89fc2bf   YunaiV   feat(iot):【协议改造】h...
46
        protocols:
c3485a3f   YunaiV   reactor:【IoT 物联网】...
47
48
49
          # ====================================
          # 针对引入的 HTTP 组件的配置
          # ====================================
e89fc2bf   YunaiV   feat(iot):【协议改造】h...
50
          - id: http-json
d357105d   YunaiV   feat(iot):【协议改造】将...
51
            protocol: http
e89fc2bf   YunaiV   feat(iot):【协议改造】h...
52
            port: 8092
cb301eb7   YunaiV   feat(iot):【协议改造】u...
53
            enabled: false
44b1950e   YunaiV   feat(iot):【协议改造】t...
54
55
56
57
          # ====================================
          # 针对引入的 TCP 组件的配置
          # ====================================
          - id: tcp-json
cb301eb7   YunaiV   feat(iot):【协议改造】u...
58
            enabled: false
d357105d   YunaiV   feat(iot):【协议改造】将...
59
            protocol: tcp
44b1950e   YunaiV   feat(iot):【协议改造】t...
60
            port: 8091
44b1950e   YunaiV   feat(iot):【协议改造】t...
61
62
63
64
            serialize: json
            tcp:
              max-connections: 1000
              keep-alive-timeout-ms: 30000
44b1950e   YunaiV   feat(iot):【协议改造】t...
65
66
67
              codec:
                type: delimiter              # 拆包类型:length_field / delimiter / fixed_length
                delimiter: "\\n"             # 分隔符(支持转义:\\n=换行, \\r=回车, \\t=制表符)
5ead81be   YunaiV   feat(iot):【协议改造】t...
68
69
70
71
72
73
74
  #              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            # 固定长度
cb301eb7   YunaiV   feat(iot):【协议改造】u...
75
76
77
78
          # ====================================
          # 针对引入的 UDP 组件的配置
          # ====================================
          - id: udp-json
68437cd8   haohao   feat:【IoT 物联网】新增 ...
79
            enabled: false
d357105d   YunaiV   feat(iot):【协议改造】将...
80
            protocol: udp
cb301eb7   YunaiV   feat(iot):【协议改造】u...
81
            port: 8093
cb301eb7   YunaiV   feat(iot):【协议改造】u...
82
83
84
            serialize: json
            udp:
              max-sessions: 1000               # 最大会话数
8e4b4cf2   YunaiV   feat(iot):【协议改造】u...
85
              session-timeout-ms: 60000        # 会话超时时间(毫秒),基于 Guava Cache 自动过期
cb301eb7   YunaiV   feat(iot):【协议改造】u...
86
87
              receive-buffer-size: 65536       # 接收缓冲区大小(字节)
              send-buffer-size: 65536          # 发送缓冲区大小(字节)
a28a1529   YunaiV   feat(iot):【协议改造】c...
88
89
90
91
          # ====================================
          # 针对引入的 WebSocket 组件的配置
          # ====================================
          - id: websocket-json
e41d66ff   YunaiV   feat(iot):【协议改造】e...
92
            enabled: false
d357105d   YunaiV   feat(iot):【协议改造】将...
93
            protocol: websocket
a28a1529   YunaiV   feat(iot):【协议改造】c...
94
            port: 8094
a28a1529   YunaiV   feat(iot):【协议改造】c...
95
96
97
98
99
100
            serialize: json
            websocket:
              path: /ws
              max-message-size: 65536          # 最大消息大小(字节,默认 64KB)
              max-frame-size: 65536            # 最大帧大小(字节,默认 64KB)
              idle-timeout-seconds: 60         # 空闲超时时间(秒,默认 60)
a28a1529   YunaiV   feat(iot):【协议改造】c...
101
102
103
104
          # ====================================
          # 针对引入的 CoAP 组件的配置
          # ====================================
          - id: coap-json
1e2dc281   YunaiV   feat(iot):【协议改造】m...
105
            enabled: false
d357105d   YunaiV   feat(iot):【协议改造】将...
106
            protocol: coap
a28a1529   YunaiV   feat(iot):【协议改造】c...
107
            port: 5683
a28a1529   YunaiV   feat(iot):【协议改造】c...
108
109
110
111
            coap:
              max-message-size: 1024           # 最大消息大小(字节)
              ack-timeout-ms: 2000             # ACK 超时时间(毫秒)
              max-retransmit: 4                # 最大重传次数
1e2dc281   YunaiV   feat(iot):【协议改造】m...
112
113
114
115
          # ====================================
          # 针对引入的 MQTT 组件的配置
          # ====================================
          - id: mqtt-json
43192207   YunaiV   feat(iot):【协议改造】m...
116
            enabled: false
d357105d   YunaiV   feat(iot):【协议改造】将...
117
            protocol: mqtt
cc0d786d   YunaiV   feat(iot):【协议改造】e...
118
            port: 1883
1e2dc281   YunaiV   feat(iot):【协议改造】m...
119
120
121
122
            serialize: json
            mqtt:
              max-message-size: 8192           # 最大消息大小(字节)
              connect-timeout-seconds: 60      # 连接超时时间(秒)
c3485a3f   YunaiV   reactor:【IoT 物联网】...
123
124
125
          # ====================================
          # 针对引入的 EMQX 组件的配置
          # ====================================
e2b995d4   YunaiV   feat(iot):【协议改造】e...
126
          - id: emqx-1
73e97d16   haohao   feat:【IoT 物联网】新增 ...
127
            enabled: false
e2b995d4   YunaiV   feat(iot):【协议改造】e...
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
            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 证书库密码
a5a3aea5   haohao   feat:【IoT 物联网】新增 ...
166
          # ====================================
fe8044c8   YunaiV   feat(iot):Modbus ...
167
          # 针对引入的 Modbus TCP Client 组件的配置
73e97d16   haohao   feat:【IoT 物联网】新增 ...
168
          # ====================================
fe8044c8   YunaiV   feat(iot):Modbus ...
169
          - id: modbus-tcp-client-1
fcca74ac   YunaiV   feat(iot):统一优化网关协...
170
            enabled: false
fe8044c8   YunaiV   feat(iot):Modbus ...
171
            protocol: modbus_tcp_client
43192207   YunaiV   feat(iot):【协议改造】m...
172
            port: 502
fe8044c8   YunaiV   feat(iot):Modbus ...
173
            modbus-tcp-client:
43192207   YunaiV   feat(iot):【协议改造】m...
174
              config-refresh-interval: 30  # 配置刷新间隔(秒)
a0db8684   YunaiV   feat(iot):1)重构 mo...
175
          # ====================================
fe8044c8   YunaiV   feat(iot):Modbus ...
176
          # 针对引入的 Modbus TCP Server 组件的配置
a0db8684   YunaiV   feat(iot):1)重构 mo...
177
          # ====================================
fe8044c8   YunaiV   feat(iot):Modbus ...
178
          - id: modbus-tcp-server-1
fcca74ac   YunaiV   feat(iot):统一优化网关协...
179
            enabled: false
fe8044c8   YunaiV   feat(iot):Modbus ...
180
            protocol: modbus_tcp_server
a0db8684   YunaiV   feat(iot):1)重构 mo...
181
            port: 503
fe8044c8   YunaiV   feat(iot):Modbus ...
182
            modbus-tcp-server:
a0db8684   YunaiV   feat(iot):1)重构 mo...
183
184
185
186
              config-refresh-interval: 30     # 配置刷新间隔(秒)
              custom-function-code: 65        # 自定义功能码(用于认证等扩展交互)
              request-timeout: 5000           # Pending Request 超时时间(毫秒)
              request-cleanup-interval: 10000 # Pending Request 清理间隔(毫秒)
c3485a3f   YunaiV   reactor:【IoT 物联网】...
187
  
d7c57f50   haohao   feat:【IoT 物联网】gat...
188
189
190
  --- #################### 日志相关配置 ####################
  
  # 基础日志配置
c3485a3f   YunaiV   reactor:【IoT 物联网】...
191
  logging:
d7c57f50   haohao   feat:【IoT 物联网】gat...
192
193
    file:
      name: ${user.home}/logs/${spring.application.name}.log # 日志文件名,全路径
c3485a3f   YunaiV   reactor:【IoT 物联网】...
194
    level:
d7c57f50   haohao   feat:【IoT 物联网】gat...
195
196
197
198
199
      # 应用基础日志级别
      cn.iocoder.yudao.module.iot.gateway: INFO
      org.springframework.boot: INFO
      # RocketMQ 日志
      org.apache.rocketmq: WARN
54a08b97   YunaiV   feat:【IoT 物联网】app...
200
201
202
203
204
      # MQTT 客户端日志
      # io.vertx.mqtt: DEBUG
      # 开发环境详细日志
      cn.iocoder.yudao.module.iot.gateway.protocol.emqx: DEBUG
      cn.iocoder.yudao.module.iot.gateway.protocol.http: DEBUG
73e97d16   haohao   feat:【IoT 物联网】新增 ...
205
      cn.iocoder.yudao.module.iot.gateway.protocol.mqtt: DEBUG
bec8cc6e   YunaiV   feat:【iot】coap 协议...
206
      cn.iocoder.yudao.module.iot.gateway.protocol.coap: DEBUG
d2c000d6   YunaiV   feat:【iot】websock...
207
      cn.iocoder.yudao.module.iot.gateway.protocol.websocket: DEBUG
a0db8684   YunaiV   feat(iot):1)重构 mo...
208
      cn.iocoder.yudao.module.iot.gateway.protocol.modbus: DEBUG
d7c57f50   haohao   feat:【IoT 物联网】gat...
209
      # 根日志级别
c3485a3f   YunaiV   reactor:【IoT 物联网】...
210
      root: INFO
d7c57f50   haohao   feat:【IoT 物联网】gat...
211
212
  
  debug: false