LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   zeroconf (python): client doesn't get to see the server (https://www.linuxquestions.org/questions/programming-9/zeroconf-python-client-doesnt-get-to-see-the-server-718899/)

eantoranz 04-13-2009 07:43 PM

zeroconf (python): client doesn't get to see the server
 
Hi!

I'm doing this little experiment to publish a network service with zeroconf. Right now I'm running both the client and the server on localhost (and perhaps that's the problem!), but the fact is that the client doesn't get to see the service that the server is publishing.

Here's the relevant code.
Server:
Code:

import Zeroconf

svc1 = Zeroconf.ServiceInfo('_durus._tcp.local.',
                              'Database 1._durus._tcp.local.',
                              address = socket.inet_aton(SERVER_ADDRESS),
                              port = SOCKET_PORT,
                              weight = 0, priority=0,
                              properties = {'description':
                                            'FLISoL Installation Finished Registration'}
                            )
Zeroconf.Zeroconf().registerService(svc1)

SERVER_ADDRESS = '127.0.0.1' in this example, also SOCKET_PORT = 9000. WHen I start the server, I see traffic on the loopback:
Code:

19:35:48.972352 IP 127.0.1.1.5353 > 224.0.0.251.5353: 0 [b2&3=0x400] [1n] PTR (QM)? _http._tcp.local. (80)
19:35:49.148143 IP 127.0.1.1.5353 > 224.0.0.251.5353: 0 [b2&3=0x400] [1n] PTR (QM)? _http._tcp.local. (80)
19:35:49.323062 IP 127.0.1.1.5353 > 224.0.0.251.5353: 0 [b2&3=0x400] [1n] PTR (QM)? _http._tcp.local. (80)
19:35:49.323519 IP 127.0.1.1.5353 > 224.0.0.251.5353: 0*- [0q] 4/0/0 PTR[|domain]
19:35:49.549251 IP 127.0.1.1.5353 > 224.0.0.251.5353: 0*- [0q] 4/0/0 PTR[|domain]
19:35:49.774401 IP 127.0.1.1.5353 > 224.0.0.251.5353: 0*- [0q] 4/0/0 PTR[|domain]
19:35:49.975129 IP 127.0.1.1.5353 > 224.0.0.251.5353: 0 [3q] SRV (QM)? ZOE._http._tcp.local. TXT (QM)? ZOE._http._tcp.local.[|domain]
19:35:50.175707 IP 127.0.1.1.5353 > 224.0.0.251.5353: 0 [3q] SRV (QM)? ZOE._http._tcp.local. TXT (QM)? ZOE._http._tcp.local.[|domain]
19:35:50.576289 IP 127.0.1.1.5353 > 224.0.0.251.5353: 0 [3q] SRV (QM)? ZOE._http._tcp.local. TXT (QM)? ZOE._http._tcp.local.[|domain]
19:35:51.376912 IP 127.0.1.1.5353 > 224.0.0.251.5353: 0 [3q] SRV (QM)? ZOE._http._tcp.local. TXT (QM)? ZOE._http._tcp.local.[|domain]
19:35:52.975873 IP 127.0.1.1.5353 > 224.0.0.251.5353: 0 [3q][|domain]
19:35:53.176473 IP 127.0.1.1.5353 > 224.0.0.251.5353: 0 [3q][|domain]
19:35:53.577075 IP 127.0.1.1.5353 > 224.0.0.251.5353: 0 [3q][|domain]
19:35:54.377646 IP 127.0.1.1.5353 > 224.0.0.251.5353: 0 [3q][|domain]
19:35:55.776465 IP 127.0.1.1.5353 > 224.0.0.251.5353: 0*- [0q] 4/0/0 PTR[|domain]
19:35:55.902193 IP 127.0.1.1.5353 > 224.0.0.251.5353: 0*- [0q] 4/0/0 PTR[|domain]
19:35:56.027232 IP 127.0.1.1.5353 > 224.0.0.251.5353: 0*- [0q] 4/0/0 PTR[|domain]
19:35:56.031536 IP 127.0.1.1.5353 > 224.0.0.251.5353: 0 [b2&3=0x400] [1n] PTR (QM)? _durus._tcp.local. (77)
19:35:56.207322 IP 127.0.1.1.5353 > 224.0.0.251.5353: 0 [b2&3=0x400] [1n] PTR (QM)? _durus._tcp.local. (77)
19:35:56.383018 IP 127.0.1.1.5353 > 224.0.0.251.5353: 0 [b2&3=0x400] [1n] PTR (QM)? _durus._tcp.local. (77)
19:35:56.383512 IP 127.0.1.1.5353 > 224.0.0.251.5353: 0*- [0q] 4/0/0 PTR[|domain]
19:35:56.609262 IP 127.0.1.1.5353 > 224.0.0.251.5353: 0*- [0q] 4/0/0 PTR[|domain]
19:35:56.834367 IP 127.0.1.1.5353 > 224.0.0.251.5353: 0*- [0q] 4/0/0 PTR[|domain]

On the client:
Code:

exec open('Zeroconf.py').read()
print "Imported"

import Zeroconf

class MyListener(object):
    def removeService(self, server, type, name):
        print "Service", repr(name), "removed"

    def addService(self, server, type, name):
        global SERVER_ADDRESS
        global SERVICE_PORT
        print "Service", repr(name), "added"
        # Request more information about the service
        info = server.getServiceInfo(type, name)
        SERVER_ADDRESS = server.address
        SERVICE_PORT = server.port
        print 'Additional info:', info

server = Zeroconf.Zeroconf()
listener = MyListener()
browser = Zeroconf.ServiceBrowser(server, "_durus._tcp.local.", listener)

# will only wait for 5 seconds
import time
print "Waiting to locate service with Zeroconf"
time.sleep(5)

if SERVER_ADDRESS == 0 or SERVICE_PORT == 0:
    print "Couldn't find registration service"
    exit(-1)

When I start the client, I see this traffic:
Code:

19:42:38.153906 IP 127.0.1.1.5353 > 224.0.0.251.5353: 0 [b2&3=0x400] [1n] PTR (QM)? _http._tcp.local. (80)
19:42:38.329811 IP 127.0.1.1.5353 > 224.0.0.251.5353: 0 [b2&3=0x400] [1n] PTR (QM)? _http._tcp.local. (80)
19:42:38.504777 IP 127.0.1.1.5353 > 224.0.0.251.5353: 0 [b2&3=0x400] [1n] PTR (QM)? _http._tcp.local. (80)
19:42:38.505561 IP 127.0.1.1.5353 > 224.0.0.251.5353: 0*- [0q] 4/0/0 PTR[|domain]
19:42:38.731442 IP 127.0.1.1.5353 > 224.0.0.251.5353: 0*- [0q] 4/0/0 PTR[|domain]
19:42:38.956632 IP 127.0.1.1.5353 > 224.0.0.251.5353: 0*- [0q] 4/0/0 PTR[|domain]
19:42:39.158126 IP 127.0.1.1.5353 > 224.0.0.251.5353: 0 [3q] SRV (QM)? ZOE._http._tcp.local. TXT (QM)? ZOE._http._tcp.local.[|domain]
19:42:39.358721 IP 127.0.1.1.5353 > 224.0.0.251.5353: 0 [3q] SRV (QM)? ZOE._http._tcp.local. TXT (QM)? ZOE._http._tcp.local.[|domain]
19:42:39.759287 IP 127.0.1.1.5353 > 224.0.0.251.5353: 0 [3q] SRV (QM)? ZOE._http._tcp.local. TXT (QM)? ZOE._http._tcp.local.[|domain]
19:42:40.559872 IP 127.0.1.1.5353 > 224.0.0.251.5353: 0 [3q] SRV (QM)? ZOE._http._tcp.local. TXT (QM)? ZOE._http._tcp.local.[|domain]
19:42:42.158797 IP 127.0.1.1.5353 > 224.0.0.251.5353: 0 [3q][|domain]
19:42:42.359377 IP 127.0.1.1.5353 > 224.0.0.251.5353: 0 [3q][|domain]
19:42:42.759965 IP 127.0.1.1.5353 > 224.0.0.251.5353: 0 [3q][|domain]
19:42:43.561666 IP 127.0.1.1.5353 > 224.0.0.251.5353: 0 [3q][|domain]
19:42:44.959447 IP 127.0.1.1.5353 > 224.0.0.251.5353: 0*- [0q] 4/0/0 PTR[|domain]
19:42:45.085191 IP 127.0.1.1.5353 > 224.0.0.251.5353: 0*- [0q] 4/0/0 PTR[|domain]
19:42:45.210185 IP 127.0.1.1.5353 > 224.0.0.251.5353: 0*- [0q] 4/0/0 PTR[|domain]
19:42:45.214745 IP 127.0.1.1.5353 > 224.0.0.251.5353: 0 PTR (QM)? _durus._tcp.local. (35)
19:42:45.714968 IP 127.0.1.1.5353 > 224.0.0.251.5353: 0 PTR (QM)? _durus._tcp.local. (35)
19:42:46.715124 IP 127.0.1.1.5353 > 224.0.0.251.5353: 0 PTR (QM)? _durus._tcp.local. (35)
19:42:48.715284 IP 127.0.1.1.5353 > 224.0.0.251.5353: 0 PTR (QM)? _durus._tcp.local. (35)

So... what am I missing? Thanks in advance


All times are GMT -5. The time now is 06:46 PM.