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 service found under Windows but working under Ubuntu VM. #84

Closed
basic-settings opened this issue Sep 28, 2016 · 10 comments

Comments

Projects
None yet
7 participants
@basic-settings
Copy link

commented Sep 28, 2016

I am facing some issues in setting up a client/ServiceBrowser that works under both Win and Linux.

I have the following set-up:

  • Win 7 connected to domain
    • Ethernet config uses IPv4 with Subnet Mask 255.255.255.0
  • Ubuntu VM running on the same system in Oracle VirtualBox with Win Ethernet as Bridged Adapter
    enp0s3 Link encap:Ethernet HWaddr 08:00:27:55:62:63 inet addr:10.121.44.95 Bcast:10.121.44.255 Mask:255.255.255.0 inet6 addr: fe80::aa6b:92c:17c4:cfc8/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:1837029 errors:0 dropped:0 overruns:0 frame:0 TX packets:110395 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:467243091 (467.2 MB) TX bytes:7871423 (7.8 MB)
  • The broadcasting systems are running on different Debian systems connected to the network domain

If I run the ServiceBrowser from Windows I don't get any return back. I used the example Browser to test the set-up.
`from zeroconf import ServiceBrowser, Zeroconf

class MyListener(object):

def remove_service(self, zeroconf, type, name):
    print("Service %s removed" % (name,))

def add_service(self, zeroconf, type, name):
    info = zeroconf.get_service_info(type, name)
    print("Service %s added, service info: %s" % (name, info))

zeroconf = Zeroconf()
listener = MyListener()
browser = ServiceBrowser(zeroconf, "_tntsrv._tcp.local.", listener)
try:
input("Press enter to exit...\n\n")
finally:
zeroconf.close()`
Running from withing Ubuntu, it returns all the available services (as expected).

I noticed that if I change HOST_ONLY_NETWORK_MASK from 255.255.255.255 to 255.255.255.0 the opposite happens, where it works under Windows but not under Ubuntu.

This seems to ocurr in line 1603
if addr.get('netmask') != HOST_ONLY_NETWORK_MASK

I'm not experienced enough to find a common ground, but is there any posibility so that it'll work under both systems?

@basic-settings

This comment has been minimized.

Copy link
Author

commented Sep 28, 2016

For the time being, removing:
if addr.get('netmask') != HOST_ONLY_NETWORK_MASK

from:
return list(set( addr['addr'] for iface in netifaces.interfaces() for addr in netifaces.ifaddresses(iface).get(address_family, []) if addr.get('netmask') != HOST_ONLY_NETWORK_MASK ))
does the trick.

@sniperlucian

This comment has been minimized.

Copy link

commented Oct 3, 2016

same here. chromecast is found on ubuntu but not on windows.

commenting out the line

if addr.get('netmask') != HOST_ONLY_NETWORK_MASK

makes it work under win7 too.

@jackha

This comment has been minimized.

Copy link

commented Oct 6, 2016

I got a similar problem with the ServiceBrowser not finding any devices. The cause was one of zeroconf's dependencies: netifaces. Installing the latest version will download version 0.10.5, but with this version it breaks my ServiceBrowser by not finding anything. Downgrading to 0.10.4 and everything works fine.

pip uninstall netifaces
pip install netifaces==0.10.4

ps. tested with zeroconf version 0.17.6 as well as 0.17.5
ps. I got a windows 32 bit environment, but I think the problem may be platform independent.

@gbiddison

This comment has been minimized.

Copy link

commented Oct 14, 2016

I can confirm this problem on python 32 under windows 7.
I have not been able to get netifaces 0.10.4 to successfully build under win7, but the change suggested by @sniperlucian does appear to get it to work.

@gbiddison

This comment has been minimized.

Copy link

commented Oct 14, 2016

The problem does not occur with 64 bit python under win7, I don't have an explanation for this though.

@bannsec

This comment has been minimized.

Copy link

commented Oct 21, 2016

The problem is occurring for me on Win10 Python 64-bit. I'm using zeroconf 0.10.5. Same as previous posters, the fix that basic-settings suggested works for me. In my Windows setting, I am not able to easily downgrade to zeroconf 0.10.4 due to not having the C++ build tools (and not wanting to install 4 gigs worth of them).

A full solution would be nice. Also, Windows wheel files for 0.10.4 would be nice as well.

gbiddison added a commit to gbiddison/python-zeroconf that referenced this issue Dec 6, 2016

gbiddison added a commit to gbiddison/python-zeroconf that referenced this issue Dec 6, 2016

Merge pull request #8 from gbiddison/dev/fix_for_upstream_84
upstream issue jstasiak#84 fix for windows compatibility
@jimmyharris

This comment has been minimized.

Copy link

commented Mar 21, 2017

I am seconding @gbiddison on this. We either need to remove this check or change setup.py line 59 to read in order to

        'netifaces<=0.10.4',

Or drop the following check from zeroconf.py line 1590

        if addr.get('netmask') != HOST_ONLY_NETWORK_MASK

Alternately we could modify the above check to only take effect on non windows platforms.

import platform

# intervening code to line 1590
        if (platform.system() == 'Windows') or (addr.get('netmask') != HOST_ONLY_NETWORK_MASK)

Either of these will fix the issue with windows compatibility.

My company would really like to use this as part of our build system, but we cannot do it if windows is not supported.

@jstasiak

This comment has been minimized.

@jstasiak

This comment has been minimized.

Copy link
Owner

commented Mar 21, 2017

Version 0.19.0 has just been released with the netifaces<=0.10.4 restriction in place, please reopen the issue if it didn't help.

@jstasiak jstasiak closed this Mar 21, 2017

@jimmyharris

This comment has been minimized.

Copy link

commented Mar 21, 2017

Thanks @jstasiak!

How long does that usually take to propagate up to PyPI?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.