Commit 1b5ff691a9fcc44674b9c47799eae734cff61c34
Committed by
GitHub
Merge pull request #5639 from YevhenBondarenko/fix/lwm2m-sessions
[3.3.3] fixed sessions updating on lwm2m transport start
Showing
3 changed files
with
9 additions
and
6 deletions
@@ -17,7 +17,6 @@ package org.thingsboard.server.transport.lwm2m.server; | @@ -17,7 +17,6 @@ package org.thingsboard.server.transport.lwm2m.server; | ||
17 | 17 | ||
18 | import lombok.RequiredArgsConstructor; | 18 | import lombok.RequiredArgsConstructor; |
19 | import lombok.extern.slf4j.Slf4j; | 19 | import lombok.extern.slf4j.Slf4j; |
20 | -import org.eclipse.californium.elements.util.SslContextUtil; | ||
21 | import org.eclipse.californium.scandium.config.DtlsConnectorConfig; | 20 | import org.eclipse.californium.scandium.config.DtlsConnectorConfig; |
22 | import org.eclipse.californium.scandium.dtls.cipher.CipherSuite; | 21 | import org.eclipse.californium.scandium.dtls.cipher.CipherSuite; |
23 | import org.eclipse.leshan.core.node.codec.DefaultLwM2mNodeDecoder; | 22 | import org.eclipse.leshan.core.node.codec.DefaultLwM2mNodeDecoder; |
@@ -29,6 +28,7 @@ import org.springframework.stereotype.Component; | @@ -29,6 +28,7 @@ import org.springframework.stereotype.Component; | ||
29 | import org.thingsboard.server.cache.ota.OtaPackageDataCache; | 28 | import org.thingsboard.server.cache.ota.OtaPackageDataCache; |
30 | import org.thingsboard.server.common.data.DataConstants; | 29 | import org.thingsboard.server.common.data.DataConstants; |
31 | import org.thingsboard.server.common.transport.config.ssl.SslCredentials; | 30 | import org.thingsboard.server.common.transport.config.ssl.SslCredentials; |
31 | +import org.thingsboard.server.queue.util.AfterStartUp; | ||
32 | import org.thingsboard.server.queue.util.TbLwM2mTransportComponent; | 32 | import org.thingsboard.server.queue.util.TbLwM2mTransportComponent; |
33 | import org.thingsboard.server.transport.lwm2m.config.LwM2MTransportServerConfig; | 33 | import org.thingsboard.server.transport.lwm2m.config.LwM2MTransportServerConfig; |
34 | import org.thingsboard.server.transport.lwm2m.secure.TbLwM2MAuthorizer; | 34 | import org.thingsboard.server.transport.lwm2m.secure.TbLwM2MAuthorizer; |
@@ -37,10 +37,7 @@ import org.thingsboard.server.transport.lwm2m.server.store.TbSecurityStore; | @@ -37,10 +37,7 @@ import org.thingsboard.server.transport.lwm2m.server.store.TbSecurityStore; | ||
37 | import org.thingsboard.server.transport.lwm2m.server.uplink.DefaultLwM2MUplinkMsgHandler; | 37 | import org.thingsboard.server.transport.lwm2m.server.uplink.DefaultLwM2MUplinkMsgHandler; |
38 | import org.thingsboard.server.transport.lwm2m.utils.LwM2mValueConverterImpl; | 38 | import org.thingsboard.server.transport.lwm2m.utils.LwM2mValueConverterImpl; |
39 | 39 | ||
40 | -import javax.annotation.PostConstruct; | ||
41 | import javax.annotation.PreDestroy; | 40 | import javax.annotation.PreDestroy; |
42 | -import java.security.PrivateKey; | ||
43 | -import java.security.PublicKey; | ||
44 | import java.security.cert.X509Certificate; | 41 | import java.security.cert.X509Certificate; |
45 | 42 | ||
46 | import static org.eclipse.californium.scandium.dtls.cipher.CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256; | 43 | import static org.eclipse.californium.scandium.dtls.cipher.CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256; |
@@ -71,7 +68,7 @@ public class DefaultLwM2mTransportService implements LwM2MTransportService { | @@ -71,7 +68,7 @@ public class DefaultLwM2mTransportService implements LwM2MTransportService { | ||
71 | 68 | ||
72 | private LeshanServer server; | 69 | private LeshanServer server; |
73 | 70 | ||
74 | - @PostConstruct | 71 | + @AfterStartUp |
75 | public void init() { | 72 | public void init() { |
76 | this.server = getLhServer(); | 73 | this.server = getLhServer(); |
77 | /* | 74 | /* |
@@ -88,7 +88,7 @@ public class LwM2mClientContextImpl implements LwM2mClientContext { | @@ -88,7 +88,7 @@ public class LwM2mClientContextImpl implements LwM2mClientContext { | ||
88 | private final Map<String, LwM2mClient> lwM2mClientsByRegistrationId = new ConcurrentHashMap<>(); | 88 | private final Map<String, LwM2mClient> lwM2mClientsByRegistrationId = new ConcurrentHashMap<>(); |
89 | private final Map<UUID, Lwm2mDeviceProfileTransportConfiguration> profiles = new ConcurrentHashMap<>(); | 89 | private final Map<UUID, Lwm2mDeviceProfileTransportConfiguration> profiles = new ConcurrentHashMap<>(); |
90 | 90 | ||
91 | - @AfterStartUp | 91 | + @AfterStartUp(order = Integer.MAX_VALUE - 1) |
92 | public void init() { | 92 | public void init() { |
93 | String nodeId = context.getNodeId(); | 93 | String nodeId = context.getNodeId(); |
94 | Set<LwM2mClient> fetchedClients = clientStore.getAll(); | 94 | Set<LwM2mClient> fetchedClients = clientStore.getAll(); |
@@ -87,6 +87,12 @@ public class DefaultLwM2MRpcRequestHandler implements LwM2MRpcRequestHandler { | @@ -87,6 +87,12 @@ public class DefaultLwM2MRpcRequestHandler implements LwM2MRpcRequestHandler { | ||
87 | return; | 87 | return; |
88 | } | 88 | } |
89 | LwM2mClient client = clientContext.getClientBySessionInfo(sessionInfo); | 89 | LwM2mClient client = clientContext.getClientBySessionInfo(sessionInfo); |
90 | + | ||
91 | + if (client == null) { | ||
92 | + log.warn("Missing client for session: [{}]", sessionInfo); | ||
93 | + return; | ||
94 | + } | ||
95 | + | ||
90 | if (client.getRegistration() == null) { | 96 | if (client.getRegistration() == null) { |
91 | this.sendErrorRpcResponse(sessionInfo, rpcRequest.getRequestId(), ResponseCode.INTERNAL_SERVER_ERROR, "Registration is empty"); | 97 | this.sendErrorRpcResponse(sessionInfo, rpcRequest.getRequestId(), ResponseCode.INTERNAL_SERVER_ERROR, "Registration is empty"); |
92 | return; | 98 | return; |