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

[BUG] lan-search for printers does not work on Windows 11 #152

Open
treitmayr opened this issue Feb 17, 2024 · 1 comment
Open

[BUG] lan-search for printers does not work on Windows 11 #152

treitmayr opened this issue Feb 17, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@treitmayr
Copy link

During further investigation for PR #150 and Issue #142 I noticed, that ankerctl.py lan-search does not work as expected on Windows 11 in that no printer is found even though the host is on the same network as the printer and the printer is turned on.
From Linux computers, the printer could be found without issues.

To Reproduce
Steps to reproduce the behavior:

  1. execute ankerctl.py lan-search on a Windows 11 computer
  2. No printer will be detected.

Expected behavior
The printer should be detected just the same as on a Linux machine.

Desktop (please complete the following information):

  • OS: Windows 11
  • Python 3.12
  • Version 1.0

Initial Analysis
The following observations where done:

  • Wireshark on the Win 11 machine did not report any UDP broadcast packets being sent out, even with the Defender Firewall being disabled.
  • A small test program just sending out UDP broadcasts to 255.255.255.255 port confirmed the issue:
#!/usr/bin/python
import socket
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
#sock.bind(("192.168.178.23", 0))      # with this the packet is actually sent on the desired interface
#sock.bind(("0.0.0.0", 0))    # does not work
#sock.bind(("", 0))           # does not work either
addr = ("255.255.255.255", 32108)
sock.sendto(b"hello", addr)
  • This SO post lead me to the solution in the script above (see comment "# with this the packet is actually sent..."). Short story, on Windows 11 the broadcast does not seem to be sent out on all interfaces, just on the "first" on (whichever this may be).

So the solution for a Windows code path might be to determine all local network addresses and send out the broadcast individually from each of these addresses. I already found a library ifaddr which seems to do the job well according to initial tests.

@treitmayr treitmayr added the bug Something isn't working label Feb 17, 2024
@treitmayr
Copy link
Author

I provided a fix in commit 2b6c402 as part of PR #150.

@treitmayr treitmayr changed the title [BUG] [BUG] lan-search for printers does not work on Windows 11 Feb 18, 2024
anselor pushed a commit to anselor/ankermake-m5-protocol that referenced this issue Mar 15, 2024
anselor pushed a commit to anselor/ankermake-m5-protocol that referenced this issue Mar 16, 2024
anselor pushed a commit to anselor/ankermake-m5-protocol that referenced this issue May 23, 2024
robertbaker pushed a commit to robertbaker/ankermake-m5-protocol that referenced this issue Sep 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant