leshan icon indicating copy to clipboard operation
leshan copied to clipboard

Strongly tie a observation to a server endpoint

Open sbernard31 opened this issue 1 year ago • 1 comments

A registration is now tied to server endpoint. (see https://github.com/eclipse-leshan/leshan/pull/1655) Then observation should also be tied to 1 server endpoint.

This will avoid Observation Token conflict between different server endpoint. (currently a token should be unique by Leshan Server with this modification a Observation Token should be unique by server endpoint)

So concretely that mean that Observation Identifier has changed.
Before it was just a CoAP token, now this is the (CoAP token + server endpoint Uri used). Unfortunately this will break RedisRegistrationStore data compatibility. (see https://github.com/eclipse-leshan/leshan/issues/1418#issuecomment-2419924978)

sbernard31 avatar Oct 11 '24 16:10 sbernard31

@JaroslawLegierski , @cyril2maq, Oops I did it again. I break the RedisRegistrationStore Data compatibility.

I let you know that as soon as possible, so we can try to anticipate issue about it.

Maybe better to read this comment : https://github.com/eclipse-leshan/leshan/issues/1415#issue-1617480570 too.

Let discuss about that here.

sbernard31 avatar Oct 17 '24 16:10 sbernard31

@JaroslawLegierski , @cyril2maq, Oops I did it again. I break the RedisRegistrationStore Data compatibility.

I let you know that as soon as possible, so we can try to anticipate issue about it.

Maybe better to read this comment : #1415 (comment) too.

Let discuss about that here.

I tested this change today and as I understand it, the change in Redis is the addition the field e.g. "epUri": "coaps://0.0.0.0:5684", in JSON presented below for the key "OBS#TKN#...." responsible for observation for partitcular LwM2M client

		{
			"id": "d53329b026af5dd2",
			"epUri": "coaps://0.0.0.0:5684",
			"regid": "mIqhc2qKmg",
			"userContext": {},
			"protocolData": {
				"leshan-cf-obs": {
					"request": "48018072d53329b026af5dd260543333303301300435373030622d17",
					"peer": {
						"address": "127.0.0.1",
						"port": 50926,
						"id": "leshan_1",
						"attributes": {
							"*DTLS_HANDSHAKE_MODE": "auto"
						}
					},
					"context": {
						"leshan-endpoint": "leshan1",
						"leshan-path": "/3303/0/5700n",
						"leshan-regId": "mIqhc2qKmg}}"
					},
					"kind": "single",
					"ct": 11543,
					"path": "/3303/0/5700"
				}
			}
		}

So the change only affects leshan clients with observation. Am I right?

JaroslawLegierski avatar Oct 24 '24 16:10 JaroslawLegierski

This is a bit more than that : see https://github.com/eclipse-leshan/leshan/issues/1418#issuecomment-2419924978

So the change only affects leshan clients with observation. Am I right?

Those keys are only about observations. But I don't know what happens if you are using an old registration using previous key with the new code in case where you don't use observations (I didn't test it)

sbernard31 avatar Oct 25 '24 08:10 sbernard31

This is a bit more than that : see #1418 (comment)

So the change only affects leshan clients with observation. Am I right?

Those keys are only about observations. But I don't know what happens if you are using an old registration using previous key with the new code in case where you don't use observations (I didn't test it)

I tested the code change on the server side. After retransmissions (we lost InMemoryReadWriteLockConnectionStore in server after server replace), the LwM2M client (Leshan client demo) initiated a new handshake and finally successfully completed the registration update. leshan_server_code_change

JaroslawLegierski avatar Oct 29 '24 15:10 JaroslawLegierski

This is a bit more than that : see #1418 (comment)

So the change only affects leshan clients with observation. Am I right?

Those keys are only about observations. But I don't know what happens if you are using an old registration using previous key with the new code in case where you don't use observations (I didn't test it)

I noticed that the secondary index "OBSIDS#REGID#.... in my Redis has always the value null

127.0.0.1:6379> keys *
1) "REG#EP#leshan1"
2) "EP#ADDR#/127.0.0.1:58045"
3) "OBSIDS#REGID#hi8A1xB0n5"
4) "OBS#OBSID#coaps://0.0.0.0:5684##\xcd\xd4z\xc4\xd70\x8c#"
5) "EP#REGID#hi8A1xB0n5"
6) "SEC#EP#leshan1"
7) "EXP#EP"
8) "EP#PSKID"
9) "EP#IDENTITY#{\"type\":\"psk\",\"pskid\":\"leshan_1\"}"
127.0.0.1:6379> mget "OBSIDS#REGID#hi8A1xB0n5"
1) (nil)

Are you also getting this error on your side? (I don't know if the problem is in my Redis or if the lpush method in RedisRegistrationStore is not working properly)

JaroslawLegierski avatar Oct 30 '24 15:10 JaroslawLegierski

OBSIDS#REGID#*has a list value. I don't know if MGET command works on it. In Leshan code we use LRANGE.

sbernard31 avatar Oct 30 '24 16:10 sbernard31

OBSIDS#REGID#*has a list value. I don't know if MGET command works on it. In Leshan code we use LRANGE.

Sure I completely forgot that this is list of values. LRAGE reads it. Thx!

JaroslawLegierski avatar Oct 31 '24 07:10 JaroslawLegierski