Part of the EllisLab Network
   
 
XML-RPC Read/Write Timeout
Posted: 23 March 2007 10:59 AM   [ Ignore ]  
Summer Student
Total Posts:  13
Joined  03-23-2007

There doesn’t seem to be a way to set a timeout on reading or writing streams in the XML-RPC library.  Although there is functionality for setting a timeout in the library, the timeout value is only used in the call to fsockopen().

The timeout parameter of fsockopen() is only used for timing out the initial connection attempt.  After the connection is established, timeouts for reading and writing data revert to default (I think five seconds?).  In order to set a timeout for reading and writing data, you need a subsequent call to stream_set_timeout().  Further complicating things, it seems that stream_set_timeout() only applies to the next operation—so if you set the timeout, write some data, and then wait for a response, you need to set the timeout again after the write.

As it is now, if you read data over XML-RPC that takes more than the default timeout to get to you, CI will erroneously close the socket and report ‘no data received’.

Fixing this properly will take some modification of the XML-RPC classes that comprise the library (not to mention some decisions on setting one timeout vs. multiple timeouts), but if you want a quick-and-dirty fix for reading data, you can put a call to stream_set_timeout() in Xmlrpc.php:

function parseResponse($fp)
    
{
        stream_set_timeout
($fp, 80);
        
        
$data = '';
        ...

The other possible problem with this is that stream_set_timeout is only part of PHP >=4.3.0.  I don’t know what CI’s policy is on PHP minimum versions, nor what you’re supposed to do for PHP versions prior to 4.3.0.

It might also make sense for CI to check the ‘timed_out’ key from the results of stream_get_meta_data() in order to provide a more informative error message.

Profile
 
 
Posted: 23 March 2007 11:45 AM   [ Ignore ]   [ # 1 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  351
Joined  07-25-2006

The user guide states the minimum version of PHP is 4.3.2, http://www.codeigniter.com/user_guide/general/requirements.html.

 Signature 

me and some random code, hosted by dh. and a blog too! ++ dead bugs

Profile
 
 
Posted: 23 March 2007 01:38 PM   [ Ignore ]   [ # 2 ]  
Summer Student
Total Posts:  13
Joined  03-23-2007

Ah, okay, good.  That means it’s just a question of calling the function after deciding how things should be handled.

Thanks for pointing out the requirements page!

Profile
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 719, on June 06, 2008 10:16 AM
Total Registered Members: 66422 Total Logged-in Users: 36
Total Topics: 84773 Total Anonymous Users: 2
Total Replies: 454928 Total Guests: 249
Total Posts: 539701    
Members ( View Memberlist )
Newest Members:  ZeerfedegheEdgedcenticeRoger_Mxcamilojoostvaningenlittleorangemanpaulevansbyroo