irmen / Pyro5

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

Passing hostname to a new Daemon object still exposes it to 127.0.0.1, is this correct? #64

Closed giacomoguiduzzi closed 2 years ago

giacomoguiduzzi commented 2 years ago

Good morning, I'm opening this issue as I just struggled for many hours to understand why I couldn't reach the server from another machine in the same LAN. My tests were done both on Windows 10 and on Ubuntu 20.04. By looking at the Pyro5 documentation about the Daemon object, it is written that passing a hostname or an IP Address binds the server to that address. I always passed as the "host" keyword argument the machine's hostname and everything worked fine until I decided to test the software connecting from another machine: I got an [Errno 111] Connection refused whatever I did. After some time I realized that using the machine's hostname bound the server to localhost, and the same behavior is shown by the pyro5-ns command as well. Is this supposed to be correct? In this case the documentation should be edited to be more clear about this. If this is not the expected behavior I'd gladly give you all the information you need to look further into this issue.

Thank you in advance, looking forward to your kind response.

Best Regards, Giacomo

irmen commented 2 years ago

Pyro doesn't usually try to be smarter than the OS unless you tell it to. This means that if your OS resolves the hostname to 127.0.0.1, there's not much Pyro can do about that.

i.e. try "ping hostname" in a shell and observe the result

So you'll have to change your DNS setup if you want this to work, or bind to 0.0.0.0 or "" , or to the explicit IP address on the network that's reachable from remote machines.

This is not really something specific to Pyro, so I don't really see how Pyro's documentation should try to explain this? Other systems/configurations can have a different result. It's all a result of the way the DNS resolver of your OS works. What kind of addition to the docs were you thinking about? Note that we already have this as well: https://pyro5.readthedocs.io/en/latest/tipstricks.html#failed-to-locate-the-nameserver-or-connection-refused-error-what-now

giacomoguiduzzi commented 2 years ago

Hi irmen,

alright, so it's an OS issue. I didn't think that the OS would associate a hostname to localhost by default but to one of the available network adapters, thank you for clarifying this point.

What I was thinking about the documentation is: reading that passage on the docs page (https://pyro5.readthedocs.io/en/stable/servercode.html#creating-a-daemon) about the creation of the Daemon object makes it look like by default the server will bind on 127.0.0.1, and setting an hostname will bind it on another address, which will not be 127.0.0.1. I thought it would be useful to clarify this point to avoid this kind of problem in the future. The page you linked surely helped me to notice this problem by the way; I think Pyro's documentation is one of the best docs I've ever read in the last few years.

What do you think about (copying from the docs page):

Best Regards, Giacomo

irmen commented 2 years ago

that makes sense, I'll adapt the paragraph. Thanks for your praise about the docs, it took a good amount of effort to reach this level, and we can still improve it further!