修复tcp保持会话断开连接后重新连接无法恢复session
This commit is contained in:
parent
d2a9902058
commit
c45634dda4
|
|
@ -1,6 +1,7 @@
|
|||
package org.jetlinks.community.network.tcp.device;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.jetlinks.core.device.DeviceOperator;
|
||||
import org.jetlinks.core.message.codec.EncodedMessage;
|
||||
import org.jetlinks.core.message.codec.Transport;
|
||||
|
|
@ -19,8 +20,10 @@ class TcpDeviceSession implements DeviceSession {
|
|||
private String id;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private DeviceOperator operator;
|
||||
|
||||
@Setter
|
||||
private TcpClient client;
|
||||
|
||||
@Getter
|
||||
|
|
|
|||
|
|
@ -209,9 +209,15 @@ class TcpServerDeviceGateway implements DeviceGateway, MonitorSupportDeviceGatew
|
|||
} else {
|
||||
client.onDisconnect(() -> sessionManager.unregister(device.getDeviceId()));
|
||||
}
|
||||
sessionRef.set(fSession);
|
||||
sessionManager.register(fSession);
|
||||
}
|
||||
try {
|
||||
fSession.unwrap(TcpDeviceSession.class)
|
||||
.setClient(client);
|
||||
} catch (Throwable ignore) {
|
||||
|
||||
}
|
||||
sessionRef.set(fSession);
|
||||
fSession.keepAlive();
|
||||
Duration timeout = message.getHeader(Headers.keepOnlineTimeoutSeconds).map(Duration::ofSeconds).orElse(keepaliveTimeout.get());
|
||||
if (timeout != null) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue