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

No MDNS services are listed by zeroconf when using Windows 11 #49

Open
Poikilos opened this issue Aug 16, 2024 · 8 comments
Open

No MDNS services are listed by zeroconf when using Windows 11 #49

Poikilos opened this issue Aug 16, 2024 · 8 comments

Comments

@Poikilos
Copy link
Contributor

This may or may not be an issue with the way I'm using zeroconf (may be my version of Cython if it uses that), because the problem seems to appear and vanish according to the issue here: python-zeroconf/python-zeroconf#1055

I have tried some different ways of using it here: https://github.com/Hierosoft/python-openlcb/tree/zeroconf-windows11-fix, but made no progress yet.

@bobjacobsen
Copy link
Owner

What do I need to do to execute that code? Just run examples_gui.py? I tried that on my Mac and didn't see anything in the top box.

@bobjacobsen
Copy link
Owner

This seems to work:

from zeroconf import ServiceBrowser, ServiceListener, Zeroconf


class MyListener(ServiceListener):

    def update_service(self, zc: Zeroconf, type_: str, name: str) -> None:
        print(f"Service {name} updated")

    def remove_service(self, zc: Zeroconf, type_: str, name: str) -> None:
        print(f"Service {name} removed")

    def add_service(self, zc: Zeroconf, type_: str, name: str) -> None:
        info = zc.get_service_info(type_, name)
        print(f"Service {name} added, service info: {info}")


zeroconf = Zeroconf()
listener = MyListener()
browser = ServiceBrowser(zeroconf, "_openlcb-can._tcp.local.", listener)
try:
    input("Press enter to exit...\n\n")
finally:
    zeroconf.close()

with output:

% python3.10 example_zeroconf.py
Press enter to exit...

Service tcs_cs_090099030035._openlcb-can._tcp.local. added, service info: ServiceInfo(type='_openlcb-can._tcp.local.', name='tcs_cs_090099030035._openlcb-can._tcp.local.', addresses=[b'\xc0\xa8\x10\xd4'], port=12021, weight=0, priority=0, server='tcs-cs-0035.local.', properties={b'OLCB': None}, interface_index=None)

@Poikilos
Copy link
Contributor Author

I don't get anything on Windows 11 from your minimal example either. Also, in examples_gui.py try clicking "detect" by IP address to fill in the top drop-down box. That will probably work as long as you are not using Windows 11. Let me know if you have trouble, but I will also try to make the interface more intuitive.

@bobjacobsen
Copy link
Owner

On my Mac, it seems like there's about a 5 second pause before the Detect button is able to click. After that, it detects the CS-105 just fine.

Not sure what to recommend for Windows 11. Something seems broken, which is surprising: There are a lot of Windows 11 machines out there.

@bobjacobsen
Copy link
Owner

Is it possible that it's one specific Windows 11 machine, and not Windows 11 in general? Can you try on another Win11 machine?

IIRC, at one point there was a component you needed to install for Windows to speak Zeroconf/Bonjour. Maybe that's missing on the Win11 machine.

@Poikilos
Copy link
Contributor Author

Poikilos commented Aug 23, 2024

Ok, yes it is only happening on certain Windows 11 machines. @MycioDan says he's had to tell people to power cycle the machine etc. to get it to work (that is going back years before Windows 11 even) before I wrote the example or any zeroconf programs for TCS, so I will probably have to do an IP address search if Windows' unreliable MDNS fails to work. I will see if there is a way to fix it by restarting MDNS or other service(s) without restarting Windows.

  • On the computers where it does work, it works with or without Bonjour installed.
  • On the computer where it eventually worked, I deleted incorrect firewall settings and on the next run, Windows prompted me. I do not however get prompts on the computer where it doesn't work, even if I delete firewall rules related to the program.

Related links:

Poikilos added a commit to Hierosoft/python-openlcb that referenced this issue Aug 23, 2024
@bobjacobsen
Copy link
Owner

Could you check whether IPv6 is enabled or not on the machines that are causing the problem? There's a JMRIusers thread where they seem to be having a problem with mDNS when IPv6 is disabled on Windows.

Poikilos added a commit to Hierosoft/python-openlcb that referenced this issue Aug 23, 2024
… adapters (revert to default zeroconf behavior; new behavior didn't help issue bobjacobsen#49). Remove WiFi restart code (didn't help with issue bobjacobsen#49).
@Poikilos
Copy link
Contributor Author

Having IPv6 enabled doesn't make the issue happen, but when I get a chance I'll try disabling it on the machine where MDNS does not work. For now I've started a diagnostic tool here: https://github.com/Hierosoft/mdnscheckup

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

No branches or pull requests

2 participants