Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call addMembership() for mdns server socket #375

Merged
merged 4 commits into from
Oct 14, 2023

Conversation

vilicvane
Copy link
Contributor

Fixes #374

@Apollon77
Copy link
Collaborator

Thank you. Interesting. I really wonder why I never had any issue on raspi and macOS. I also had the membership thing in before but it never really made any difference.

But maybe this also could describe issues under windows that were reported.

I will release the current main branch as 0.6 tomorrow. After this I will check out your changes on my systems.

@vilicvane
Copy link
Contributor Author

vilicvane commented Oct 8, 2023

@Apollon77 I just come out with a theory and did some test and I think that might be the cause.

On Ubuntu (WSL 2), and probably macOS and raspi, membership might be "shared" cross processes. While on Windows it's not.

I tried similar script, and adding membership in another process works on Ubuntu but not Windows. And as there are probably already other services setting up mDNS servers on macOS and raspi, so it's not a problem without adding membership again.

Test scripts for convenience:

script-1.mjs

import { createSocket } from "dgram";

const server = createSocket({ type: "udp4", reuseAddr: true });

server.bind(5353, () => {
    // server.addMembership("224.0.0.251");
});

server.on("message", (data, { address }) => {
    console.log(address, data);
});

const client = createSocket({ type: "udp4", reuseAddr: true });

client.bind(5353, () => {
    setInterval(() => client.send("Hello", 5353, "224.0.0.251"), 1000);
});

script-2.mjs

import { createSocket } from "dgram";

const server = createSocket({ type: "udp4", reuseAddr: true });

server.bind(5353, () => {
    server.addMembership("224.0.0.251");
});

@Apollon77
Copy link
Collaborator

Thank you. And yes these might be the reasons. I will test out code mainly to make sure that it "still works" for the systems where it worked before ;-)

@Apollon77 Apollon77 merged commit 0e844ba into project-chip:main Oct 14, 2023
@vilicvane vilicvane deleted the fix/mdns-server-membership branch October 14, 2023 07:42
@Apollon77
Copy link
Collaborator

Apollon77 commented Oct 14, 2023

@vilic There was a reportin discord about these erros in log

Error: addMembership ENODEV
    at Socket.addMembership (node:dgram:852:11)
    at UdpChannelNode.create (/etc/nixos/matter.js/packages/matter-node.js/dist/cjs/net/UdpChannelNode.js:100:18)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async UdpMulticastServer.create (/etc/nixos/matter.js/packages/matter.js/dist/cjs/net/UdpMulticastServer.js:61:50)
    at async MdnsServer.create (/etc/nixos/matter.js/packages/matter.js/dist/cjs/mdns/MdnsServer.js:73:7)
    at async MdnsBroadcaster.create (/etc/nixos/matter.js/packages/matter.js/dist/cjs/mdns/MdnsBroadcaster.js:58:7)
    at async MatterServer.start (/etc/nixos/matter.js/packages/matter.js/dist/cjs/MatterServer.js:91:30)
    at async main (/etc/nixos/index.js:105:5) {
  errno: -19,
  code: 'ENODEV',
  syscall: 'addMembership'
}

nodejs: v18.16.1
nixos: 23.11

I think we need to make sure that such error are simply logged and ignored ...

@vilicvane
Copy link
Contributor Author

@Apollon77 Okay I'll send a new PR soon. Possibly due to no network according to some: mafintosh/multicast-dns#34

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

UdpMulticastServer not receiving messages
2 participants