[Twisted-Python] Anomaly found between twisted XML-RPC client and twisted server (Bug?)

Wari Wahab wari at home.wari.org
Thu May 22 05:08:04 EDT 2003


Hi there, I was testing around the XML-RPC support in twisted and found 
the following:
same twisted client and server (one instance) = error.connectionLost
twisted client -> twisted server = error.connectionLost
xmlprclib client -> twisted server = got my results
twisted client -> xmlrpclib client = got my results.

First time round, the twisted xmlrpc client sits together with the 
server in one application, the client calls on a reactor.callLater(). 
This does not work, so I figured I must be doing something wrong. I 
split up the client and the server and I got the same error, split up 
the program network wise, again the same error, on the client, its:
[Failure instance: Traceback: twisted.internet.error.ConnectionLost,]
and on the Server:
2003/05/22 23:30 SGT [HTTPChannel,5,192.168.10.15] Traceback (most 
recent call last):
          File 
"/usr/lib/python2.2/site-packages/twisted/protocols/basic.py", line 173, 
in dataReceived
            self.lineReceived(line)
          File 
"/usr/lib/python2.2/site-packages/twisted/protocols/http.py", line 893, 
in lineReceived
            self.allContentReceived()
          File 
"/usr/lib/python2.2/site-packages/twisted/protocols/http.py", line 932, 
in allContentReceived
            req.requestReceived(command, path, version)
          File 
"/usr/lib/python2.2/site-packages/twisted/protocols/http.py", line 504, 
in requestReceived
            self.process()
        --- <exception caught here> ---
          File "/usr/lib/python2.2/site-packages/twisted/web/server.py", 
line 156, in process
            self.render(resrc)
          File "/usr/lib/python2.2/site-packages/twisted/web/server.py", 
line 162, in render
            body = resrc.render(self)
          File "/usr/lib/python2.2/site-packages/twisted/web/xmlrpc.py", 
line 103, in render
            args, functionPath = xmlrpclib.loads(request.content.read())
          File 
"/var/tmp/python-2.2.2-root/usr/lib/python2.2/xmlrpclib.py", line 805, 
in loads
            p.close()
          File 
"/var/tmp/python-2.2.2-root/usr/lib/python2.2/xmlrpclib.py", line 393, 
in close
            self._parser.Parse("", 1) # end of data
        xml.parsers.expat.ExpatError: no element found: line 1, column 0

Here's what I did in detail:

The server is the exact one found at 
http://twistedmatrix.com/documents/howto/xmlrpc
The client is something like the one I found at the same page as well, 
but this time on an interactive python session.
----------------
Python 2.2.2 (#1, May 19 2003, 14:32:06)
[GCC 2.96 20000731 (Red Hat Linux 7.2 2.96-112.7.2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
 >>> from twisted.web.xmlrpc import Proxy
 >>> from twisted.internet import reactor
 >>>
 >>> def printValue(value):
...     print repr(value)
...     reactor.stop()
...
 >>> def printError(error):
...     print 'error', error
...     reactor.stop()
...
 >>> p = Proxy('http://192.168.11.1:7080')
 >>> #### Calling the add method with twisted
 >>> p.callRemote('add', 3, 5).addCallbacks(printValue, printError)
<Deferred at 0x83d3f84>
 >>> reactor.run()
error [Failure instance: Traceback: twisted.internet.error.ConnectionLost,
]
 >>> from xmlrpclib import Server
 >>> s=Server('http://192.168.11.1:7080')
 >>> #### Calling the add method with xmlrpclib
 >>> s.add(3,5)
8
 >>> p = Proxy('http://some.web.site/RPC2')
 >>> #### Using proxy again to talk to an xmlrpclib based server (pyblosxom)
 >>> p.callRemote('blogger.getUsersBlogs', '', 'myusername', 
'mypassword').addCallbacks(printValue, printError)
<Deferred at 0x83e8ac4>
 >>> reactor.run()
[{'url': 'http://some.web.site/blog/', 'blogid': '/', 'blogName': '/'}, 
{'url': 'http://some.web.site/blog/GeekyStuff/', 'blogid': 
'/GeekyStuff/', 'blogName': '/GeekyStuff/'}]
 >>>
-----------------
What could be happening here?






More information about the Twisted-Python mailing list