agnat / node_wake_on_lan

Wake-on-LAN utilities for node.js
MIT License
222 stars 24 forks source link

not working from windows #4

Closed vstreammedia closed 6 years ago

vstreammedia commented 9 years ago

The sample code works perfectly fine from MacOS but is not running on Windows. any idea why? same Node versions on both machines.

Regards, Andrés.

agnat commented 9 years ago

No clue really...

Some sort of firewall preventing outgoing UDP broadcasts?

Maybe use wireshark to make sure windows actually sends a packet and it looks the same as on mac os?

mwittig commented 8 years ago

Hi guys! Apparently, the problem is the routing behaviour for the global broadcast address on Windows as the IP packets will only be propagated through the first network interface found. The following article describes the matter. Work-around: Set the "address" property to the broadcast address for your local network / the subnet. Here is an example which works for my setup.

wol.wake(theMac, { address: "192.168.178.255" }, wakeCB);

EDIT: If you're not sure how to calculate the broadcast address see this article or simply use an online calculator

agnat commented 8 years ago

Thanks @mwittig. This is really helpful. IP address and net mask are available at runtime using os.networkInterfaces().

mwittig commented 8 years ago

Yes, os.networkInterfaces() can be used to collect all netmasks to send the wol packet via each interface. Note, however, "netmask" is not included in node v0.10. Unfortunately, I have still to support v0.10 in some of my projects. See also https://github.com/nodejs/node-v0.x-archive/issues/5731

agnat commented 6 years ago

I added a note to the README in 1c4f1ed01d6fe427d8bb4b98c7a469c001d041c8.