Question

I'm rather new to Python and Pyro4, and am trying to figure out how to work with them. My problem is that, given the below server and client code my two computers cannot seem to talk to each other. They are both running Ubuntu 12.04 and are on the same local network and can ping (and ssh) each other. The server IP is 192.168.0.18 and the client is 192.168.0.22.

Here's the (very basic) server code I've played with (server):

import Pyro4

class dispatcher(object):
    def __init__(self):
        self.name = "Dispatcher"
        self.version = "0.1"

    def request_work(self):
        print("Someone requested work!")
        return ['Work']

disp = dispatcher()
daemon = Pyro4.Daemon(host="192.168.0.18", port=5150)
Pyro4.Daemon.serveSimple(
    { disp: "test.dispatcher" },
    ns=False,
    daemon=daemon,
    verbose = True
)

This runs and outputs the following:

/usr/local/lib/python2.7/dist-packages/Pyro4-4.14-py2.7.egg/Pyro4/core.py:155:    UserWarning: HMAC_KEY not set, protocol data may not be secure warnings.warn("HMAC_KEY not set, protocol data may not be secure") 
Object <__main__.dispatcher object at 0x7ff21f9a6b90>:
uri = PYRO:mb.dispatcher@192.168.0.18:5150
Pyro daemon running.

And on the client:

import Pyro4
di = Pyro4.Proxy("PYRO:test.dispatcher@192.168.0.18:5150")
di.request_work()

And after a few moments this returns:

Pyro4.errors.CommunicationError: cannot connect: [Errno 110] Connection timed out

I've also tried setting Pyro4.config.HOST = '192.168.0.18' instead of setting up the daemon, but no luck.

Any ideas why this is not working, or things that I'm doing wrong?

Was it helpful?

Solution

I'm not sure about this problem. Did you open the name service for Pyro4? Based on the tutorial, I usually execute the following shell

python -Wigonre -m Pyro4.naming --host [your ip] --port [your port]

This shell can provides the name service for Pyro4 and I usually use the PYRONAME instead of PYRO.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top