review:【iot 物联网】mqtt 协议
This commit is contained in:
parent
73e97d1675
commit
14336002f3
@ -353,7 +353,6 @@ public class IotGatewayProperties {
|
|||||||
* 连接超时时间(秒)
|
* 连接超时时间(秒)
|
||||||
*/
|
*/
|
||||||
private Integer connectTimeoutSeconds = 60;
|
private Integer connectTimeoutSeconds = 60;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 保持连接超时时间(秒)
|
* 保持连接超时时间(秒)
|
||||||
*/
|
*/
|
||||||
@ -363,7 +362,6 @@ public class IotGatewayProperties {
|
|||||||
* 是否启用 SSL
|
* 是否启用 SSL
|
||||||
*/
|
*/
|
||||||
private Boolean sslEnabled = false;
|
private Boolean sslEnabled = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SSL 配置
|
* SSL 配置
|
||||||
*/
|
*/
|
||||||
@ -379,27 +377,22 @@ public class IotGatewayProperties {
|
|||||||
* 密钥证书选项
|
* 密钥证书选项
|
||||||
*/
|
*/
|
||||||
private io.vertx.core.net.KeyCertOptions keyCertOptions;
|
private io.vertx.core.net.KeyCertOptions keyCertOptions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 信任选项
|
* 信任选项
|
||||||
*/
|
*/
|
||||||
private io.vertx.core.net.TrustOptions trustOptions;
|
private io.vertx.core.net.TrustOptions trustOptions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SSL 证书路径
|
* SSL 证书路径
|
||||||
*/
|
*/
|
||||||
private String certPath;
|
private String certPath;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SSL 私钥路径
|
* SSL 私钥路径
|
||||||
*/
|
*/
|
||||||
private String keyPath;
|
private String keyPath;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 信任存储路径
|
* 信任存储路径
|
||||||
*/
|
*/
|
||||||
private String trustStorePath;
|
private String trustStorePath;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 信任存储密码
|
* 信任存储密码
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -50,6 +50,7 @@ public class IotMqttUpstreamProtocol {
|
|||||||
this.serverId = IotDeviceMessageUtils.generateServerId(mqttProperties.getPort());
|
this.serverId = IotDeviceMessageUtils.generateServerId(mqttProperties.getPort());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO @haohao:这里的编写,是不是和 tcp 对应的,风格保持一致哈;
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
public void start() {
|
public void start() {
|
||||||
// 创建服务器选项
|
// 创建服务器选项
|
||||||
|
|||||||
@ -46,7 +46,9 @@ public class IotMqttConnectionManager {
|
|||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// 忽略异常,返回默认值
|
// 忽略异常,返回默认值
|
||||||
|
// TODO @haohao:这个比较稳定会出现哇?
|
||||||
}
|
}
|
||||||
|
// TODO @haohao:这个要枚举下么?
|
||||||
return "unknown";
|
return "unknown";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -194,4 +196,5 @@ public class IotMqttConnectionManager {
|
|||||||
private boolean authenticated;
|
private boolean authenticated;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -69,7 +69,6 @@ public class IotMqttDownstreamHandler {
|
|||||||
|
|
||||||
// 5. 发送消息到设备
|
// 5. 发送消息到设备
|
||||||
return sendMessageToDevice(message, connectionInfo, payload);
|
return sendMessageToDevice(message, connectionInfo, payload);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
if (message != null) {
|
if (message != null) {
|
||||||
log.error("[handleDownstreamMessage][处理下行消息异常,设备 ID:{},错误:{}]",
|
log.error("[handleDownstreamMessage][处理下行消息异常,设备 ID:{},错误:{}]",
|
||||||
|
|||||||
@ -40,6 +40,7 @@ public class IotMqttUpstreamHandler {
|
|||||||
|
|
||||||
public IotMqttUpstreamHandler(IotMqttUpstreamProtocol protocol,
|
public IotMqttUpstreamHandler(IotMqttUpstreamProtocol protocol,
|
||||||
IotDeviceMessageService deviceMessageService,
|
IotDeviceMessageService deviceMessageService,
|
||||||
|
// TODO @haohao:用不到的 deviceService 可以删除哈;
|
||||||
IotDeviceService deviceService,
|
IotDeviceService deviceService,
|
||||||
IotMqttConnectionManager connectionManager) {
|
IotMqttConnectionManager connectionManager) {
|
||||||
this.deviceMessageService = deviceMessageService;
|
this.deviceMessageService = deviceMessageService;
|
||||||
@ -70,6 +71,7 @@ public class IotMqttUpstreamHandler {
|
|||||||
|
|
||||||
log.info("[handle][设备认证成功,建立连接,客户端 ID: {},用户名: {}]", clientId, username);
|
log.info("[handle][设备认证成功,建立连接,客户端 ID: {},用户名: {}]", clientId, username);
|
||||||
|
|
||||||
|
// TODO @haohao:这里是不是少了序号哈?
|
||||||
// 设置异常和关闭处理器
|
// 设置异常和关闭处理器
|
||||||
endpoint.exceptionHandler(ex -> {
|
endpoint.exceptionHandler(ex -> {
|
||||||
log.warn("[handle][连接异常,客户端 ID: {},地址: {}]", clientId, getEndpointAddress(endpoint));
|
log.warn("[handle][连接异常,客户端 ID: {},地址: {}]", clientId, getEndpointAddress(endpoint));
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user