PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Web Services » XML_RPC » Bug #3963

Timeout incorrectly implemented in client.

Details

Submitted2005-03-25 23:32 UTC
Frommfriedman at symcor dot com
Assigneddanielc
StatusClosed
PackageXML_RPC
PHP VersionIrrelevant
OSLinux / slackware
Roadmaps(Not assigned)

Comments

[2005-03-25 23:32 UTC] mfriedman at symcor dot com

Description:
------------
In the XML_RPC_Client::sendPayloadHTTP10() method, the timeout arg is passed directly into the fsockopen call.

<code>
if ($timeout > 0) {
$fp = @fsockopen($protocol . $server, $port,
$this->errno, $this->errstr, $timeout);
}
</code>

This won't handle the case where the socket is connected but the rpc server is slow and processing takes longer than the client's timeout value. I believe this is the intention of the feature, but the current implementation doesn't satisfy this requirement.

Reviewing the docs for fsockopen I found this note:

Note: If you need to set a timeout for reading/writing data over the socket, use stream_set_timeout(), as the timeout parameter to fsockopen() only applies while connecting the socket. (from http://php.net/fsockopen)

Therefore, you can't really check for a timeout error - for instance, if the server is slow to respond to a request; the socket will have connected right away in this case - as such, in the current implementation, there isn't a way to handle timeouts of the type I'm speaking of - even though there appears to be.

I suggest passing the timeout argument to stream_set_timeout() instead as the docs recommend.

Comments and docs at: http://php.net/manual/en/function.stream-set-timeout.php are also helpful for this.

Thanks,