eclipse-californium / californium

CoAP/DTLS Java Implementation

Home Page:https://www.eclipse.org/californium/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

lwm2m-service deployu in k8s,can not return client message

hedong2021 opened this issue · comments

when I deploy Californium lwm2m-service in k8s ,config udp type, then i send a request to Californium lwm2m-service
the Californium lwm2m-service can receive client message, but when i return message through method :
public T send(final Registration destination, final DownlinkRequest request,
Long timeout)
can not success, client can receive message, i think server no send for some reason

if  i  deploy   Californium lwm2m-service out k8s  ,this no problem, client can receive message.

please why?

public T send(final Registration destination, final DownlinkRequest request, Long timeout)

Leshan?

Not sure, what happens in your case. You provided close to no information.
Some years ago I was working with k8s. At that time it was possible to use Californium in k8s.
I guess, this is still true, but it's to long ago, that I can be of too much help.

Californium is not aware to run in a container. Therefore the sending of messages is not related to that. But if the container or service description is wrong, then the traffic may get dropped there.

If you like, you may check k8s for some ideas.

Leshan? yes, I use org.eclipse.californium-2.0.0-M5 this version;

where I excute this code: WriteResponse checkResponse = lwM2mServer.send(registration, checkRequest, TIMEOUT);

I foud code enter below this method:
public T send(final Registration destination, final DownlinkRequest request,
Long timeout) throws InterruptedException {

    // Retrieve the objects definition
    final LwM2mModel model = modelProvider.getObjectModel(destination);

    // Create the CoAP request from LwM2m request
    CoapRequestBuilder coapRequestBuilder = new CoapRequestBuilder(
            new InetSocketAddress(destination.getAddress(), destination.getPort()), destination.getRootPath(),
            destination.getId(), destination.getEndpoint(), model, encoder);
    request.accept(coapRequestBuilder);
    final Request coapRequest = coapRequestBuilder.getRequest();

    // Send CoAP request synchronously
    SyncRequestObserver<T> syncMessageObserver = new SyncRequestObserver<T>(coapRequest, timeout) {
        @Override
        public T buildResponse(Response coapResponse) {
            // Build LwM2m response
            LwM2mResponseBuilder<T> lwm2mResponseBuilder = new LwM2mResponseBuilder<>(coapRequest, coapResponse,
                    destination, model, observationService, decoder);
            request.accept(lwm2mResponseBuilder);
            return lwm2mResponseBuilder.getResponse();
        }
    };
    coapRequest.addMessageObserver(syncMessageObserver);

    // Store pending request to cancel it on de-registration
    addPendingRequest(destination.getId(), coapRequest);

    // Send CoAP request asynchronously
    Endpoint endpoint = getEndpointForClient(destination);
    endpoint.sendRequest(coapRequest);
    // Wait for response, then return it
    return syncMessageObserver.waitForResponse();
}

then i find endpoint.sendRequest(coapRequest); can not excute success to return message
and No prompts and logs about the send return

and I try Capture packets ,but There was no return message either

Under normal circumstances, excute endpoint.sendRequest(coapRequest); can print below message:

2024-04-19 09:24:33: 64 FINER [ReliabilityLayer]: Send request, failed transmissions: 0 - (org.eclipse.californium.core.network.stack.ReliabilityLayer.java:87) sendRequest() in thread CoapServer#2
2024-04-19 09:24:33: 64 FINER [UdpMatcher]: Tracking open request [MID: 26,152, Token: 0073fa7d5a4d24e4] - (org.eclipse.californium.core.network.UdpMatcher.java:106) sendRequest() in thread CoapServer#2
2024-04-19 09:24:33: 59 FINER [UDPConnector$Sender]: UDPConnector (coap://0.0.0.0:55683) sends 165 bytes to /172.20.225.88:56,846 - (org.eclipse.californium.elements.UDPConnector$Sender.java:345) work() in thread UDP-Sender-0.0.0.0/0.0.0.0:55683[0]
2024-04-19 09:24:35: 71 FINE [ReliabilityLayer$RetransmissionTask]: Timeout: retransmission limit reached, exchange failed, message: CON-PUT MID=26152, Token=0073fa7d5a4d24e4, OptionSet={"Uri-Path":["5","0"], "Content-Format":"application/vnd.oma.lwm2m+tlv"},
c8 01 5b 63 6f 61 70 3a 2f 2f 74 65 73 74 2e 6f 73 2e 63 6d 69 6f 74 63 64 2e 63 6f 6d 3a 39 36

As I wrote:
If the docker container is build well (you didn't show your Dockerfile),
and the k8s configuration is well (you also don't show that), then in
my experience everything works well. There is no code in Californium,
which is related to running in a container or not.

If even the logging isn't as you assume, I guess, the configuration for that inside the container isn't well.
I don't know, how leshan configures that, you need to ask the leshan project.

Californium 3.11. demos are using logback as logging backend, but that may be different for leshan.
Logback is configured with logback.xml and that is copied into the container with the resulting jar. If someone wants to modify it, then it requires to copy the modified logback.xml into the container similar as the Californium properties file COPY ./CaliforniumReceivetest3.properties /opt/app/

I use org.eclipse.californium-2.0.0-M5 this version;

Please, be precise:

  • do you use Californium 2.0.0-M5 (Sep 7, 2017),
  • or Leshan 2.0.0-M5 (Oct 21, 2021), that includes Californium 3.0.0-RC1 (Oct 13, 2021).

In both cases: please update.

If no more information is provided, I can't help.
Could this ticket be closed?