xmlrpclib hangs execution

Tijs tijs_news at artsoftonline.com
Wed May 30 10:54:56 EDT 2007


Arno Stienen wrote:

> Arno Stienen wrote:
>> Perhaps I should be a bit more specific. When using this code to connect
>> to a remote XML-RPC server (C++, xmlrpc++0.7 library):
>> 
>>            import xmlrpclib
>>            server = xmlrpclib.Server("http://10.10.101.62:29500")
>>            print server.Connection_Request("roberto")
>> 
>> the Python command line 'hangs' until I kill the server. Then, the
>> correct output is suddenly displayed:
>> 
>>            {'state': 0, 'id_session': '2Z3EUSLJFA13', 'port': 29501,
>>            'str': 'Connection accepted. Session attached.'}
>> 
>> Yet a slightly simpler call works flawlessly:
>> 
>>            import xmlrpclib
>>            server = xmlrpclib.Server("http://10.10.101.62:29500")
>>            print server.Info_RT('Master')
>> 
>>            {'state': 0, 'str': 'Info_RT'}
>> 

After having a quick look at your files, I conclude that the problem is in a
combination of two problems:

1. Your server is crap. It answers an HTTP/1.0 request by an HTTP/1.1
response without specifying any Connection header and without closing the
connection. Normally, a simple client that is not HTTP/1.1-aware expects
the connection to close. HTTP/1.1 leaves the connection open by default.

2. The Python implementation of xmlrpc is not very robust. It just waits for
the connection to close. A well-written client (like your Java client)
would detect the presence of a Content-Length header and use that. 

The other request is OK because the server closes the connection after
having sent the response. Why the difference? Don't know, but it is
something server-side. 

Try to force the server to send HTTP/1.0 responses, or turn off keep-alive,
or something like that. Otherwise, adapt xmlrpclib.py to robustly handle
1.1 responses.

-- 

Regards,
Tijs



More information about the Python-list mailing list