[EMAIL PROTECTED] schrieb:
Hello everyone
Can someone help me fix this problem?

I am using an example from Pyro(Python Remote Object) website
directly.
It is the last example from
http://pyro.sourceforge.net/manual/8-example.htm

I have two computers to run Server and Client.
############################################
server.py

import Pyro.naming
import Pyro.core
from Pyro.errors import PyroError,NamingError


###### testclass Pyro object

class testclass(Pyro.core.ObjBase):
    def mul(s, arg1, arg2): return arg1*arg2
    def add(s, arg1, arg2): return arg1+arg2
    def sub(s, arg1, arg2): return arg1-arg2
    def div(s, arg1, arg2): return arg1/arg2

###### main server program

def main():
        Pyro.core.initServer()
        daemon = Pyro.core.Daemon()
        # locate the NS
        locator = Pyro.naming.NameServerLocator()
        print 'searching for Name Server...'
        ns = locator.getNS(host='drizzle.des.hep.uiuc.edu', port=9090)
        daemon.useNameServer(ns)

        # connect a new object implementation (first unregister
previous one)
        try:
                # 'test' is the name by which our object will be known
to the outside world
                ns.unregister('test')
        except NamingError:
                pass

        # connect new object implementation
        daemon.connect(testclass(),'test')

        # enter the server loop.
        print 'Server object "test" ready.'
        daemon.requestLoop()

if __name__=="__main__":
        main()

###################################

###################################
client.py

import Pyro.naming, Pyro.core
from Pyro.errors import NamingError

# locate the NS
locator = Pyro.naming.NameServerLocator()
print 'Searching Name Server...',
ns = locator.getNS(host='drizzle.des.hep.uiuc.edu',port=9090)

# resolve the Pyro object
print 'finding object'
try:
        URI=ns.resolve('test')
        print 'URI:',URI
except NamingError,x:
        print 'Couldn\'t find object, name server says:',x
        raise SystemExit

# create a proxy for the Pyro object, and return that
test = Pyro.core.getProxyForURI(URI)

print test.mul(111,9)
print test.add(100,222)
print test.sub(222,100)
print test.div(2.0,9.0)
print test.mul('*',10)
print test.add('String1','String2')
#######################################

It does not matter which computer Pyro NameServer is located.
When Server and Client are in a same computer, it works perfectly
fine.
But whenever Server and Client run in different computers, I get a
following error message.


########################################
Pyro Client Initialized. Using Pyro V3.7
Searching Name Server... finding object
URI: PYRO://127.0.0.1:7888/7f000001193649ab6a89d5592bc843bb
Traceback (most recent call last):
 File "client.py", line 22, in <module>
   print test.mul(111,9)
 File "/usr/local/lib/python2.5/site-packages/Pyro/core.py", line
390, in __call__
   return self.__send(self.__name, args, kwargs)
 File "/usr/local/lib/python2.5/site-packages/Pyro/core.py", line
467, in _invokePYRO
   self.adapter.bindToURI(self.URI)
 File "/usr/local/lib/python2.5/site-packages/Pyro/protocol.py", line
255, in bindToURI
   raise ProtocolError('connection failed')
Pyro.errors.ProtocolError: connection failed
########################################

Thanks a lot.

THis is just a guess - but it seems that somehow you don't bind your pyro objects to the NIC's IP address, but to localhost (127.0.0.1) - which of course won't work. That never happened to me though, try and see the pyro docs on how to prevent/control to which IP a proxy is bound.

Diez
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to