Commit b5da59e3b38e230ac50639020ab2c96b54cac5fa

Authored by YevhenBondarenko
1 parent 615f5173

fixed double sending rpc (private network)

... ... @@ -117,6 +117,10 @@ public class LwM2mClient implements Serializable {
117 117 @Getter
118 118 private final AtomicInteger retryAttempts;
119 119
  120 + @Getter
  121 + @Setter
  122 + private Integer lastSentRpcId;
  123 +
120 124 public Object clone() throws CloneNotSupportedException {
121 125 return super.clone();
122 126 }
... ...
... ... @@ -95,6 +95,9 @@ public class DefaultLwM2MRpcRequestHandler implements LwM2MRpcRequestHandler {
95 95 this.sendErrorRpcResponse(sessionInfo, rpcRequest.getRequestId(), ResponseCode.INTERNAL_SERVER_ERROR, "Registration is empty");
96 96 return;
97 97 }
  98 + if (client.getLastSentRpcId() != null && client.getLastSentRpcId().equals(rpcRequest.getRequestId())) {
  99 + log.info("[{}] Rpc has already sent!", rpcRequest.getRequestId());
  100 + }
98 101 try {
99 102 if (operationType.isHasObjectId()) {
100 103 String objectId = getIdFromParameters(client, rpcRequest);
... ...
... ... @@ -45,6 +45,7 @@ public abstract class RpcDownlinkRequestCallbackProxy<R, T> implements DownlinkR
45 45
46 46 @Override
47 47 public void onSent(R request) {
  48 + client.setLastSentRpcId(this.request.getRequestId());
48 49 transportService.process(client.getSession(), this.request, RpcStatus.SENT, TransportServiceCallback.EMPTY);
49 50 }
50 51
... ... @@ -68,6 +69,7 @@ public abstract class RpcDownlinkRequestCallbackProxy<R, T> implements DownlinkR
68 69 @Override
69 70 public void onError(String params, Exception e) {
70 71 if (e instanceof TimeoutException || e instanceof org.eclipse.leshan.core.request.exception.TimeoutException) {
  72 + client.setLastSentRpcId(null);
71 73 transportService.process(client.getSession(), this.request, RpcStatus.TIMEOUT, TransportServiceCallback.EMPTY);
72 74 } else if (!(e instanceof ClientSleepingException)) {
73 75 sendRpcReplyOnError(e);
... ...