Repository navigation
Closed
Description
Sorry this may be a known issue at this early stage, but I thought I will add it here for record.
When I try to use the chip-tool to pair with the node-matter, I get following error.
Command:
chip-tool pairing ethernet 222 20202021 3840 192.168.1.28 5540
Matter server listening
Pase: Received pairing request from udp://192.168.1.57:51566 on session unsecure
Pase: Paired succesfully with udp://192.168.1.57:51566 on session unsecure
Received read request from udp://192.168.1.57:51566 on session secure/40941: */49/65532, 0/48/0, 0/48/1, 0/48/2, 0/48/3, 0/40/2, 0/40/4, */49/3
Received invoke request from udp://192.168.1.57:51566 on session secure/40941: 0/48/0
Received invoke request from udp://192.168.1.57:51566 on session secure/40941: 0/48/2
Received invoke request from udp://192.168.1.57:51566 on session secure/40941: 0/62/2
Received invoke request from udp://192.168.1.57:51566 on session secure/40941: 0/62/2
Received invoke request from udp://192.168.1.57:51566 on session secure/40941: 0/62/0
Received invoke request from udp://192.168.1.57:51566 on session secure/40941: 0/62/4
Received invoke request from udp://192.168.1.57:51566 on session secure/40941: 0/62/11
Received invoke request from udp://192.168.1.57:51566 on session secure/40941: 0/62/6
/usr/lib/node_modules/node-matter/build/codec/TlvObjectCodec.js:75
throw new Error(`Missing mandatory field ${key}`);
^
Error: Missing mandatory field rcacId
at TlvObjectCodec.decodeObject (/usr/lib/node_modules/node-matter/build/codec/TlvObjectCodec.js:75:27)
at TlvObjectCodec.decodeInternal (/usr/lib/node_modules/node-matter/build/codec/TlvObjectCodec.js:58:29)
at TlvObjectCodec.decodeObject (/usr/lib/node_modules/node-matter/build/codec/TlvObjectCodec.js:72:32)
at TlvObjectCodec.decodeInternal (/usr/lib/node_modules/node-matter/build/codec/TlvObjectCodec.js:58:29)
at TlvObjectCodec.decodeElement (/usr/lib/node_modules/node-matter/build/codec/TlvObjectCodec.js:25:21)
at TlvObjectCodec.decode (/usr/lib/node_modules/node-matter/build/codec/TlvObjectCodec.js:22:21)
at FabricBuilder.setNewOpCert (/usr/lib/node_modules/node-matter/build/fabric/Fabric.js:66:83)
at OperationalCredentialsCluster.<anonymous> (/usr/lib/node_modules/node-matter/build/interaction/cluster/OperationalCredentialsCluster.js:56:32)
at Generator.next (<anonymous>)
at /usr/lib/node_modules/node-matter/build/interaction/cluster/OperationalCredentialsCluster.js:8:71
Node.js v18.4.0
Metadata
Metadata
Assignees
Labels
No labels
Activity
mfucci commentedon Jun 23, 2022
chip-tool: is this the command line tool part of the chip project?
I was not able to compile it on my side, so I didn't test against it...
Can you try with this change if it fixes this issue?
#5
jdesai61 commentedon Jun 23, 2022
With that fix, I can progress much further. But still no success. Attached file contains the output from chip-tool which may be useful for you. Please ignore responses from other local devices on the network. The output from node-matter his below (I tried to start the MdnsServer too but it didn't help).
chip-tool-output.txt
mfucci commentedon Jun 24, 2022
Per chip-tool logs, there seems to be an issue with the tool where it cannot send the MDNS query to look for the device:
[1655998595.210273][594134:594139] CHIP:DIS: MINMDNS: Sending query ANY/UNICAST for C6F71DCB89470DEB-00000000000000DE._matter._tcp.local
[1655998595.210987][594134:594139] CHIP:DIS: Warning: Attempt to mDNS broadcast failed on docker0: ../examples/chip-tool/third_party/connectedhomeip/src/inet/UDPEndPointImplSockets.cpp:417: OS Error 0x02000065: Network is unreachable
[1655998595.211999][594134:594139] CHIP:DIS: Warning: Attempt to mDNS broadcast failed on br-96dd142c33c5: ../examples/chip-tool/third_party/connectedhomeip/src/inet/UDPEndPointImplSockets.cpp:417: OS Error 0x02000065: Network is unreachable
chip-tool might be missing the MDNS announcement and it seems that it is not able to send a query.
You might try:
_ checking if "avahi-browse --all" is working on your environment
_ run chip-tool as admin to check if this is a permission issue
jdesai61 commentedon Jun 27, 2022
The above warnings about failed mDNS are for other network interfaces (docker0 etc). The mDNS broadcast actually does go out on the interface of interest, The difference I found was that chip-tool is sending
where as Android CHIPTool is sending
Perhaps the matter mDNS handling these differently.
jdesai61 commentedon Jun 27, 2022
Following changes seem to make further into commissioning process with chip-tool:
Change
to
Clearly the hard-coded IP address needs to be passed in using command line tool or such.
Further, since the chip-tool sends type:ANY query, the MdnsServer needs to handle RecordType:Any (0xff). I tried to make the following change
From
TO
But above change is likely incorrect, because I am not sure if ANY response should send PTR and TXT record separately. Hope this helps.
jdesai61 commentedon Jun 27, 2022
With changes in attached file, I am able to pair with chip-tool and CHIPTool, but these do not seem totally legit to me (even if I were to fix hardcoded IP address), so I am sending this file as an attachment that you can use to make proper changes
changes.zip
mfucci commentedon Jun 28, 2022
Thanks for this debugging!
I created a new pull request with fixes for the issues above: #6
It might also fix the issue with the server listening on the wrong interface, you can test it with hardcoding the IP (it should listen to all interfaces by default).
Let me know if this works!
jdesai61 commentedon Jun 28, 2022
This still doesn't work. As far as I can tell, there is no way to send multicast to all interfaces using only one send(). One must set a destination interface or let it choose a default one.
https://nodejs.org/api/dgram.html#socketaddmembershipmulticastaddress-multicastinterface
I can make this branch work with getIpMacAddresses() returning hardcoded IP and changing the bind call to:
jdesai61 commentedon Jun 28, 2022
Further, to join multicast on all interfaces, it may be necessary to
call socket.addMembership on each interface.
mfucci commentedon Jun 28, 2022
As far as I understand, multicast and broadcast are two different methods for sending data over UDP.
MDNS is based on broadcast and not multicast, so there should be no need to call setMulticastInterface or addMembership.
I think broadcast is: send a packet to everyone on the subnet. The packet won't be forwarded to other subnets by routers
And multicast is: send a packet to a group of machines, potentially located on other subnets
By maybe I am wrong, I am not an expert of this...
That said, if it works for you after calling setMulticastInterface, this method should have some side effects. The documentation for this method only talks about multicast though...
Can you describe your environment with docker?
Maybe I can reproduce your environment and the issue on my side (I just have one Linux laptop and one Android phone with me since I am travelling).
jdesai61 commentedon Jun 28, 2022
Socket/networking is my area of expertise. MDNS is based on Multicast IP (https://en.wikipedia.org/wiki/Multicast_DNS). Your understanding of subnet-broadcast is correct (except local broadcast address 255.255.255.255).
My environment:
I have two Ubuntu machines running as VMs (one as docker container on QNAP and one as QNAP Ubuntu station).
Machine 1 - docker container running ubuntu - 192.168.1.27 - where I run chip-tool
Machine 2 - Ubuntu station - 192.168.1.28 - where I run node-matter
Both machines have multiple IP interfaces
Machine 1(chip-tool)
Machine 2(node-matter)
jdesai61 commentedon Jun 28, 2022
This tries to explain the complex topic
https://stackoverflow.com/questions/10692956/what-does-it-mean-to-bind-a-multicast-udp-socket
For receiving data:
When you bind UDP socket to a specific port, with IPADDR_ANY, you will receive any traffic sent to that port (multicast or otherwise).
When you use addMembership(multicastAddress, [multicastInterface]), in addition to receiving traffic sent to the specific port, the socket will also receive traffic sent to the specified multicast address. One can call addMembership multiple times, with multiple multicast address/multicast interafce pair on the same socket and it will receive data for multiple multicast address (including different interfaces if specified)
For sending data:
Datagram is only sent to one interface (unless the machine is a multicast router - in mycase this is not the case). Unless interface is specified by setMulticastInterface, a system default interface is chosen when sending a multicast packet (which in my case seems to be the wrong one).
jdesai61 commentedon Jun 28, 2022
If MdnsServer was part of a generic MDNS server, it may be reasonable to support multiple interfaces. However, since most matter devices are likely to have only one network interface, it is reasonable for node-matter's version of MdnsServer to not support multiple interfaces and when there are multiple interfaces, let the user specify one using a command line (i.e. --ip-addr 'IP-ADDRESS' or such).
mfucci commentedon Jun 29, 2022
OK, thanks for those info, I understand my mistakes now on this.
I think I should support sending to all interfaces since it is expected that the interface changes, or that multiple interface are present, part of the Matter protocol: the device can act as an WiFi AP first before receiving WiFi credentials during the commissioning (not supported yet).
What I should do:
_ use a different UDP socket to listen and to send data
_ when asked to announce the device, the MDNS should send an announcement on all interface
_ when replying to a query, the MDNS should reply on that interface only (and with the right IP for the server)
I can add a parameter later to restrict to one interface...
I will try to implement this change today, this doesn't seem to be too hard to implement
jdesai61 commentedon Jul 7, 2022
Just checking to see if you had any luck getting to this? thanks
mfucci commentedon Jul 7, 2022
Sorry, my family and I caught Covid and we just recovered... I have a patch ready but I haven't had the chance to test it yet.
I will test and send it this weekend, sorry for the delay...
jdesai61 commentedon Jul 7, 2022
NP - I was just checking - you don't owe any deadlines to me and family always comes first. Thanks
mfucci commentedon Jul 11, 2022
Here is the pull request: #7
I tested it with an USB and a Wifi interfaces and it seems to work in my configuration.
Let me know if it works for you!
This change should make it more resilient to network changes: I recompute MDNS records on each query, so it should return the correct values even if the IP changes.
mfucci commentedon Jul 11, 2022
I think of all issues in this thread have been addressed by #7 and #5