Necessary for fixing this issue - yet - not enough. Why - read below.
I'm PR-ing this part for now because I think this is uncontroversial and is necessary anyway.
Problem: I forgot that the peer node ID is only unique in the context of a concrete fabric, so if we want to uniquely identify a node, this is done by the pair (fabric-index/fabric-id, node-id) and not just node-id.
The PR is slightly bigger, as I took the liberty to rename node_id to peer_node_id in the subscription context, as well as in the called transport methods. I think this is worthwhile, or else node_id can be interpreted as our node ID, which is incorrect of course.
=================
Why is this fix not enough? (I'm seeking your advise what could be the problem.)
Apple Matter is a bit weird. Putting aside the fact that we are commissioned into two fabrics, the other weird thing that happens is that once we are commissioned in the second fabric, they are communicating with us on behalf of TWO different IP addresses, which - however - do represent the same node+fabric ID?!
IP Address 1 (in my case): fe80::8d7:cf23:8b0b:f715%2 - in fact this guy has two different nodes, one on fabric 1, and another on fabric 2 - see our session dump below
IP Address 2: fe80::416:93dd:216a:d50a%2 - this guy has the only one node on fabric 1 (or so we know), but its node on Fabric 1 is the same as the node of the previous IP!
And now the real weird part: we receive a subscription request from IP Address 2 and this all goes well.
But when the time comes to report on that subscription in some seconds / minutes and initiate a new exchange, it just so happens that we select an existing session for "IP Address 1" instead, because we are just looking for a session matching the fabric index (=1) and the node ID. And since the first address also has created sessions to us on behalf of fabric 1, we just happen to pick a session for IP Address 1, even if the subscription came from IP Address 2.
... and get "Invalid Subscription" from the other peer.
Now, if we pick a session based on fabric index + peer node ID + remote address, then we select a session with "IP Address 2" (the address from where the subscription came) and all is well!
So @kedars what do you think is going on? Shall I just also keep the IP address in the subscription data and do a match by that address too? This works (confirmed) but sounds a bit weird. Am I missing something in the spec?
Necessary for fixing this issue - yet - not enough. Why - read below.
I'm PR-ing this part for now because I think this is uncontroversial and is necessary anyway.
Problem: I forgot that the peer node ID is only unique in the context of a concrete fabric, so if we want to uniquely identify a node, this is done by the pair
(fabric-index/fabric-id, node-id)
and not justnode-id
.The PR is slightly bigger, as I took the liberty to rename
node_id
topeer_node_id
in the subscription context, as well as in the called transport methods. I think this is worthwhile, or elsenode_id
can be interpreted as our node ID, which is incorrect of course.=================
Why is this fix not enough? (I'm seeking your advise what could be the problem.)
Apple Matter is a bit weird. Putting aside the fact that we are commissioned into two fabrics, the other weird thing that happens is that once we are commissioned in the second fabric, they are communicating with us on behalf of TWO different IP addresses, which - however - do represent the same node+fabric ID?!
fe80::8d7:cf23:8b0b:f715%2
- in fact this guy has two different nodes, one on fabric 1, and another on fabric 2 - see our session dump belowfe80::416:93dd:216a:d50a%2
- this guy has the only one node on fabric 1 (or so we know), but its node on Fabric 1 is the same as the node of the previous IP!And now the real weird part: we receive a subscription request from IP Address 2 and this all goes well. But when the time comes to report on that subscription in some seconds / minutes and initiate a new exchange, it just so happens that we select an existing session for "IP Address 1" instead, because we are just looking for a session matching the fabric index (=1) and the node ID. And since the first address also has created sessions to us on behalf of fabric 1, we just happen to pick a session for IP Address 1, even if the subscription came from IP Address 2.
... and get "Invalid Subscription" from the other peer.
Now, if we pick a session based on fabric index + peer node ID + remote address, then we select a session with "IP Address 2" (the address from where the subscription came) and all is well!
So @kedars what do you think is going on? Shall I just also keep the IP address in the subscription data and do a match by that address too? This works (confirmed) but sounds a bit weird. Am I missing something in the spec?
Session dump: