eclipse-leshan / leshan

Java Library for LWM2M
https://www.eclipse.org/leshan/
BSD 3-Clause "New" or "Revised" License
643 stars 407 forks source link

Requests initiated by LWM2M Server get sent to wrong LWM2M client with same IP:Port #187

Closed DanielMaier-BSI closed 6 years ago

DanielMaier-BSI commented 7 years ago

When a request to a LWM2M client, e.g. read request, gets triggered, Leshan looks up the client with the desired endpoint name from the client registry and sends the request to the IP:Port saved there. When this IP:Port gets used by another client in the meantime, e.g. port re-usage of NAT device, the request gets sent to the wrong client. I think without usage of DTLS this behavior is just fine.

However, the same applies also with DTLS. Example:

One way to solve this would be to handover recipient principal somehow to scandium and scandium only sends the message when this is the same as the active DTLS session. Or even more strict handover the DTLS sessionId etc. of the last message received from the according client to scandium (like Scandium CorrelationContext but only the other way around).

See also mailing list discussion: http://dev.eclipse.org/mhonarc/lists/leshan-dev/msg00610.html

sbernard31 commented 6 years ago

Thx to the great works done by @boaks. This should be fixed in this PR #440. A test was added to check that : https://github.com/eclipse/leshan/pull/440/commits/5292951027750e812ecbca36d3b5de2255953c28

Feedback is welcome :)