irmen / Pyro5

Pyro 5 - Python remote objects
https://pyro5.readthedocs.io
MIT License
305 stars 36 forks source link

Struggling to get Pyro5 working in a LAN #31

Closed pmagwene closed 3 years ago

pmagwene commented 3 years ago

I'm having a hard time getting Pyro5 working between machines in a LAN.

On the machine running the nameserver, I'm starting the nameserver with a command like:

pyro5-ns --host 10.0.0.29

I then run the greeting-server.py example from the docs.

On the local machine (the one running the nameserver), I can connect to the nameserver, use ns.list() and ns.lookup() to find example.greeting and get a URI, and then use the URI with Proxy to get a proxy object with which I can access GreetingMaker.get_fortune().

From the remote machine I can also connect to the nameserver, and use ns.list() and ns.lookup() to find example.greeting and it's URI. But when I get the URI via ns.lookup() the nameserver always returns the a URI ending in localhost. Unsurprisingly, I can't access the remote object because it's not on localhost.

I've played around with the nathost/natport settings in the Daemon but that doesn't seem to help, and in fact seems to prevent access on the local machine.

I've done some basic troubleshooting to try and insure that my problems are not firewall related. I've tried with firewalls off on both machines, without any difference in behavior. To further eliminate network misconfiguration as the source of the problems, I've tried the basic ZeroMQ (via pyzmq) examples between my local and remote machine and those work fine.

In any case, I'm looking for the simplest possible example illustrating how to use the Pyro5 nameserver to get Pyro5 working across to machines in a LAN. Any guidance would be greatly appreciated.

irmen commented 3 years ago

Sounds like the Pyro daemon is binding on a local network interface, one that isn't visible from other machines in the network. It will happily publish that IP in the name server though.

Have you checked this https://pyro5.readthedocs.io/en/latest/tipstricks.html#failed-to-locate-the-nameserver-or-connection-refused-error-what-now

irmen commented 3 years ago

An easy solution may be to not bind the daemon on the default host, but instead use "" or perhaps even the actual machine's hostname. As long as the resulting IP address is from a non-local network adapter so that it is reachable from other machines.

irmen commented 3 years ago

Any luck trying the above?

pmagwene commented 3 years ago

My apologies for the slow response.

I did eventually solve my issue though it was now far enough back that I don't recall that exact details. If I call correctly the key problem was a confusion on my part between the daemon port and the nameserver port.

irmen commented 3 years ago

Thanks @pmagwene for reporting back. Glad you managed to solve the issue!