Re: Pyro 4 help - please? :)
"Aaron Wylie" <[email protected]> Tue, 21 Oct 2014 13:02:29 -0700
| Newsgroups | gmane.comp.python.pyro |
|---|---|
| Message-ID | <[email protected]> |
Ok, a bit more progress. See my notes starting with "From Aaron 2:" -----Original Message----- From: Irmen de Jong [mailto:[email protected]] Sent: Tuesday, October 21, 2014 12:06 PM To: [email protected] Subject: Re: [Pyro] Pyro 4 help - please? :) Hello, Because the original mail wasn't sent to the mailing list I'm taking the liberty to copy part of the context of Aaron's questions here again: " I have a Windows 7 64-bit machine that I'm using to host my main application. I will have 6 Raspberry Pis attached via Ethernet to a router that the Windows box is also attached to (I only have 1 setup right now - which is good enough for my dev purposes). I have a working samba share between the pi and the windows box. On the Windows 7 machine I have Python 2.7.6, and Pyro4 (4.28). My Windows PC is names 'GOATS' (don't ask) Along with hosting my main application (which I understand will be the pyro client to each of the pis serving their individual functions) the windows box is also the name server for the application. " On to Aaron's mail: On 21-10-2014 20:20, Aaron Wylie wrote: >> I get a traceback that ends with "Pyro4.errors.NamingError: Failed to >> locate the nameserver". When I substitute the i.p. of the nameserver >> computer instead of "GOATS", it finds it perfectly. > > At what line does the error occur? > Definitely some form of DNS issue going on here, what happens when you > run the locateNS call on your windows box itself? Can you 'ping > GOATS' from the pi? Maybe it works better when you use a fully > qualified domain name ("goats.mynetwork.lan" whatever it is)? > >>From Aaron: It chokes on this line "Pyro4.locateNS(host="GOATS", port=9090)" > when running from the pi. The error is "Pyro4.errors.NamingError: > Failed to locate the nameserver". I can run the locateNS call on my > windows box, with the name 'GOATS', and it seems to be working. I did > a 'pyro4-nsc list' on the same machine and I see my frequency function > listed. I've looked at my computer properties and it only has "GOATS" listed for both 'computer name' > and 'full computer name'. Is there something I need to enter into my > hosts file? Should this matter? Well if you want to use the hostname ("GOATS") as part of the Uri you have to make sure your Pi's can resolve that to the ip address of the windows box. The easiest way to do that is by putting it in the hosts file of each Pi unit, I guess. Setting up a working dns is arguably better but perhaps overkill for your situation >From Aaron 2: I've entered "192.168.1.147 GOATS" into the /etc/hosts file of the pi and I can how ping the windows box from the pi using the windows box name. Cool! Regarding setting up a DNS, is that something out-of-the-box with Windows 7, or do I need a 3rd party app? (http://sourceforge.net/projects/dhcp-dns-server/?source=typ_redirect) Currently I can ping each computer by name (including the pi) from Windows 7, I just can't ping any machine from the pi without manually updating the /etc/hosts file. >>From Aaron: Ok, that makes sense. So, just to clarify, in the function > server code I have hosted by the pi I have (and of course the > reference to 'GOATS' doesn't work yet): > > daemon = Pyro4.Daemon() > ns = Pyro4.locateNS(host="GOATS", port=9090) uri = > daemon.register(Frequency()) ns.register("frequency", uri) > daemon.requestLoop() That is valid but problematic code due to the daemon binding on localhost by default. I'm reviewing the docs on this right now and think it could perhaps be improved a bit to make this clearer https://github.com/irmen/Pyro4/issues/63 >From Aaron 2: Cool >>From Aaron: Do I need to use Pyro4.socketutil.getIpAddress() or > Pyro4.socketutil.getInterfaceAddress() somewhere in there as well? If > so, can you show me how? You should not have to deal with these methods directly, they're pretty low level. What you could do is simply binding the daemon on the pi's externally visible interface. So say the ip address of the pi is 192.168.1.147 you could do: daemon = Pyro4.Daemon(host="192.168.1.147") and carry on with the rest of your code as given. Substitute the ip address with the pi's hostname if that resolves correctly. If you don't want to hardcode the ip address and the hostname doesn't resolve correctly, then you can use Pyro4.socketutil.getIpAddress("") or Pyro4.socketutil.getIpAddress("hostnameofthePi"). >From Aaron 2: I was able to use 'daemon = Pyro4.Daemon(host="pi-001")' and it registered with the nameserver (pi-001 is the name of the pi. Original, I know.) "frequency --> PYRO:obj_45212471e7c741a7b9d0b38f8b875094@pi-001:44441" Though, when I called the client.py script it gave me the same error that it was "actively refused". Weird, because pinging pi-001 from Windows 7 returns the pi ip address just fine. BUT! When I use 'daemon = Pyro4.Daemon(host="192.168.1.139")' in the server function, everything registers and works! Yay!! I tried using Pyro4.socketutil.getIpAddress("hostnameofthePi") and it just returned 127.0.1.1 which doesn't help me from the windows 7 side. I would prefer to stay away from hardcoded ip addresses if possible. >>From Aaron: I was poking around for some logs yesterday. Where would >>they be > hanging out? You'll have to enable them first to make them appear. Usually it will be a file called Pyro.log in the current directory, but that's configurable: http://pythonhosted.org/Pyro4/tipstricks.html#logging >From Aaron 2: K, I'll follow the instructions on that page. (adapt the unix shell syntax to windows cmd.exe syntax when on your windows box) >>From Aaron: So, now that I've gone through this with you, maybe I'm >>seeing 2 > issues. > 1.) the pi cannot see and resolve "GOATS" and therefore cannot > register a function on the windows box without using the IP address of the windows box. Correct; fix the dns or use ip address directly > 2.) when the function on the pi registers with the windows name server > (via the ip address), the object appears to run on localhost, not on > the pi. This comes down to a network adapter binding issue which I > need a bit of direction on. > Is this your take? It is. The small change you need to make is described earlier. I'll have a look at the docs to see if I can improve them a little on this matter. I guess the info is too fragmented, and not really explained in the tutorial paragraph either (that does mention it). >From Aaron: Cool! Irmen ---------------------------------------------------------------------------- -- Comprehensive Server Monitoring with Site24x7. Monitor 10 servers for $9/Month. Get alerted through email, SMS, voice calls or mobile push notifications. Take corrective actions from your mobile device. http://p.sf.net/sfu/Zoho _______________________________________________ Pyro-core mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/pyro-core ------------------------------------------------------------------------------ Comprehensive Server Monitoring with Site24x7. Monitor 10 servers for $9/Month. Get alerted through email, SMS, voice calls or mobile push notifications. Take corrective actions from your mobile device. http://p.sf.net/sfu/Zoho