473,320 Members | 1,691 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Pyro: ProtocolError('connection failed')

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.
Jul 2 '08 #1
2 3833
ja********@gmail.com 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
Jul 2 '08 #2

Diez B. Roggisch wrote:
>
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.
This problem has been discussed quite a bit on the Pyro mailinglist. What's happening is
that Pyro is indeed binding the server on the loopback adapter (making it invisible from
the outside). It does this because of what I (and several others) believe to be a bug in
the default hosts file of many linux distributions: the local hostname resolves to the
loopback adapter's address 127.0.0.1 instead of a sensible IP address.

Pyro provides some ways to work around this issue, if you can't or won't fix the
/etc/hosts file.

--irmen
PS I've replied to the original poster by private email conversation. I'm filtering
newsgroups posts that originate from google groups, hence I only saw this message
because of Diez's reply.
Jul 2 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

42
by: Irmen de Jong | last post by:
Pickle and marshal are not safe. They can do harmful things if fed maliciously constructed data. That is a pity, because marshal is fast. I need a fast and safe (secure) marshaler. Is xdrlib the...
6
by: Michael Urman | last post by:
Hi. I'm a user of python for about 3 years now. I've written a client-server application that uses SimpleXMLRPCServer and xmlrpclib.ServerProxy to communicate. It's intended to be used by a...
6
by: JudgeDread | last post by:
hello python gurus I would like to establish a socket connection to a server running a service on port 29999. the host address is 10.214.109.50. how do i do this using python? many thanks
3
by: Michael Rybak | last post by:
Hi, everyone. In topic "2-player game, client and server at localhost", I've asked about subj, and Peter Hansen suggested to switch to Twisted, Pyro or the like. I've tried using Pyro. I've...
1
by: Zri Man | last post by:
The Error in play is CLI Driver] SQL30020N Execution failed because of a Distributed Protocol Error that will affect the successful execution of subsequent commands and SQL statements: Reason Code...
0
by: adam | last post by:
I'm using Pyro to develop a distribuited system running my integration test suite I've found a strange behaviour it seems that whenever I have a failed resolve or unregister on a name server,...
7
by: Jay Balapa | last post by:
Hello, We have a Pocket PC client application which just connects to our webservice. When a client connects his Pocket PC through his WIFI he gets the following- Unable to read data from the...
2
by: =?ISO-8859-1?Q?S=E9bastien_Ramage?= | last post by:
Hi ! I'm trying to build an client/server app based on Pyro and sqlite3. But I have a problem using sqlite3 on the server I got this error : sqlite3.ProgrammingError: ('SQLite objects...
0
by: Gustavo Rahal | last post by:
Hi I'm trying to build a xmlrpc client that uses a proxy to connect to a xmlrpc server in https. I've googled and came up with a code snippet that doesn't actually work. What is missing?
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.