Skip to content

Error "Missing mandatory field rcacId" when pairing with chip-tool command #3

Closed

Description

@jdesai61

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

Activity

  1. mfucci commented on Jun 23, 2022

    @mfucci
    Owner

    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

  2. jdesai61 commented on Jun 23, 2022

    @jdesai61
    CollaboratorAuthor

    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).

    Matter server listening
    Pase: Received pairing request from udp://192.168.1.27:46919
    Pase: Paired succesfully with udp://192.168.1.27:46919
    Received read request from udp://192.168.1.27:46919 on session secure/54316: */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.27:46919 on session secure/54316: 0/48/0
    Received invoke request from udp://192.168.1.27:46919 on session secure/54316: 0/48/2
    Received invoke request from udp://192.168.1.27:46919 on session secure/54316: 0/62/2
    Received invoke request from udp://192.168.1.27:46919 on session secure/54316: 0/62/2
    Received invoke request from udp://192.168.1.27:46919 on session secure/54316: 0/62/0
    Received invoke request from udp://192.168.1.27:46919 on session secure/54316: 0/62/4
    Received invoke request from udp://192.168.1.27:46919 on session secure/54316: 0/62/11
    Received invoke request from udp://192.168.1.27:46919 on session secure/54316: 0/62/6
    ***DEBUG*** getIpMacAddresses: return hardcoded IP and MAC (eth1) 192.168.1.28 00:16:3e:05:9c:51
    ***DEBUG*** MdnsServer localHostname=00163E059C510000.local
    ***DEBUG*** MdnsServer start
    *** DEBUG *** MDNS announce
    

    chip-tool-output.txt

  3. mfucci commented on Jun 24, 2022

    @mfucci
    Owner

    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

  4. jdesai61 commented on Jun 27, 2022

    @jdesai61
    CollaboratorAuthor

    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

    C6F71DCB89470DEB-00000000000000DE._matter._tcp.local: type ANY, class IN, "QM" question
    

    where as Android CHIPTool is sending

    0CAD065775328009-0000000000000045._matter._tcp.local: type SRV, class IN, "QM" question
    0CAD065775328009-0000000000000045._matter._tcp.local: type TXT, class IN, "QM" question
    

    Perhaps the matter mDNS handling these differently.

  5. jdesai61 commented on Jun 27, 2022

    @jdesai61
    CollaboratorAuthor

    Following changes seem to make further into commissioning process with chip-tool:
    Change

            this.server.bind(MDNS_BROADCAST_PORT, MDNS_BROADCAST_IP);
    

    to

            this.server.bind(MDNS_BROADCAST_PORT, () => {
                                   this.server.setMulticastInterface('192.168.1.28')
                                   });
    

    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

            const answers = message.queries.flatMap(({name, recordType}) => this.records.filter(record => record.name === name && record.recordType === recordType));
    

    TO

            const answers = message.queries.flatMap(({name, recordType}) => this.records.filter((record => record.name === name &&
                 ((record.recordType === recordType) || (recordType === RecordType.ANY)))));
    

    But above change is likely incorrect, because I am not sure if ANY response should send PTR and TXT record separately. Hope this helps.

  6. jdesai61 commented on Jun 27, 2022

    @jdesai61
    CollaboratorAuthor

    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

  7. mfucci commented on Jun 28, 2022

    @mfucci
    Owner

    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!

  8. jdesai61 commented on Jun 28, 2022

    @jdesai61
    CollaboratorAuthor

    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:

          this.server.bind(MDNS_BROADCAST_PORT, () => {
                                  this.server.setMulticastInterface(this.ip)
                                  });
    
  9. jdesai61 commented on Jun 28, 2022

    @jdesai61
    CollaboratorAuthor

    Further, to join multicast on all interfaces, it may be necessary to
    call socket.addMembership on each interface.

  10. mfucci commented on Jun 28, 2022

    @mfucci
    Owner

    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).

  11. jdesai61 commented on Jun 28, 2022

    @jdesai61
    CollaboratorAuthor

    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)

    #ifconfig -a
    br-96dd142c33c5: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
            inet 172.18.0.1  netmask 255.255.0.0  broadcast 172.18.255.255
            ether 02:42:00:c4:6e:ce  txqueuelen 0  (Ethernet)
            RX packets 0  bytes 0 (0.0 B)
            RX errors 0  dropped 0  overruns 0  frame 0
            TX packets 0  bytes 0 (0.0 B)
            TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
    
    docker0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
            inet 172.17.0.1  netmask 255.255.0.0  broadcast 172.17.255.255
            ether 02:42:b3:7f:d2:2e  txqueuelen 0  (Ethernet)
            RX packets 0  bytes 0 (0.0 B)
            RX errors 0  dropped 0  overruns 0  frame 0
            TX packets 0  bytes 0 (0.0 B)
            TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
    
    ens3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
            inet 192.168.1.27  netmask 255.255.255.0  broadcast 192.168.1.255
            inet6 fe80::5054:ff:feed:2921  prefixlen 64  scopeid 0x20<link>
            ether 52:54:00:ed:29:21  txqueuelen 1000  (Ethernet)
            RX packets 103158235  bytes 26396197543 (26.3 GB)
            RX errors 0  dropped 14016266  overruns 0  frame 0
            TX packets 1998058  bytes 3338990578 (3.3 GB)
            TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
    
    lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
            inet 127.0.0.1  netmask 255.0.0.0
            inet6 ::1  prefixlen 128  scopeid 0x10<host>
            loop  txqueuelen 1000  (Local Loopback)
            RX packets 358798  bytes 198570548 (198.5 MB)
            RX errors 0  dropped 0  overruns 0  frame 0
            TX packets 358798  bytes 198570548 (198.5 MB)
            TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
    

    Machine 2(node-matter)

    #ifconfig -a
    eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
            inet 10.0.7.2  netmask 255.255.255.0  broadcast 10.0.7.255
            inet6 fe80::6042:ad91:7d09:88e9  prefixlen 64  scopeid 0x20<link>
            ether 00:16:3e:5e:2b:76  txqueuelen 1000  (Ethernet)
            RX packets 1663686  bytes 6997314042 (6.9 GB)
            RX errors 0  dropped 0  overruns 0  frame 0
            TX packets 962380  bytes 68931215 (68.9 MB)
            TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
    
    eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
            inet 192.168.1.28  netmask 255.255.255.0  broadcast 192.168.1.255
            inet6 fe80::9c5d:5156:d299:6da4  prefixlen 64  scopeid 0x20<link>
            ether 00:16:3e:05:9c:51  txqueuelen 1000  (Ethernet)
            RX packets 11857337  bytes 2244975634 (2.2 GB)
            RX errors 0  dropped 1656721  overruns 0  frame 0
            TX packets 266195  bytes 28972207 (28.9 MB)
            TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
    
    lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
            inet 127.0.0.1  netmask 255.0.0.0
            inet6 ::1  prefixlen 128  scopeid 0x10<host>
            loop  txqueuelen 1000  (Local Loopback)
            RX packets 1350713  bytes 84030452 (84.0 MB)
            RX errors 0  dropped 0  overruns 0  frame 0
            TX packets 1350713  bytes 84030452 (84.0 MB)
            TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
    
  12. jdesai61 commented on Jun 28, 2022

    @jdesai61
    CollaboratorAuthor

    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).

  13. jdesai61 commented on Jun 28, 2022

    @jdesai61
    CollaboratorAuthor

    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).

  14. mfucci commented on Jun 29, 2022

    @mfucci
    Owner

    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

  15. jdesai61 commented on Jul 7, 2022

    @jdesai61
    CollaboratorAuthor

    Just checking to see if you had any luck getting to this? thanks

  16. mfucci commented on Jul 7, 2022

    @mfucci
    Owner

    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...

  17. jdesai61 commented on Jul 7, 2022

    @jdesai61
    CollaboratorAuthor

    NP - I was just checking - you don't owe any deadlines to me and family always comes first. Thanks

  18. mfucci commented on Jul 11, 2022

    @mfucci
    Owner

    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.

  19. mfucci commented on Jul 11, 2022

    @mfucci
    Owner

    I think of all issues in this thread have been addressed by #7 and #5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions