Re: [PHP] XMLRPC and file_get_contents



Stut wrote:
Andreas Schlicker wrote:
Hi all,

I'm writing an XML-REC client in PHP, based on the following example:

<?php
$request = xmlrpc_encode_request("method", array(1, 2, 3));
$context = stream_context_create(array('http' => array(
'method' => "POST",
'header' => "Content-Type: text/xml",
'content' => $request
)));
$file = file_get_contents("http://www.example.com/xmlrpc";, false, $context);
$response = xmlrpc_decode($file);
if (xmlrpc_is_fault($response)) {
trigger_error("xmlrpc: $response[faultString] ($response[faultCode])");
} else {
print_r($response);
}
?>

If the XMLRPC call takes longer than say 30 seconds, the file_get_contents method doesn't returns null, and the script finishes. However, the XMLRPC server is not finished with the computation and gets a broken pipe since the client has already closed the connection.

Is there some timeout? Am I doing something wrong?

There could be several timeouts at work here. First you can set a timeout in the context[1]. Second the PHP request time limit[2]. And finally your web server (assuming this is running through a web server) will have its own timeout - check the documentation for whatever server you're using for details.

[1] http://php.net/wrappers.http
[2] http://php.net/set_time_limit

Hi Stut,

I already used the set_time_limit to set a script running timeout. Looks like the problem was the timeout in the context.

Thanks very much for you help.

Andreas
.



Relevant Pages

  • Re: [PHP] XMLRPC and file_get_contents
    ... I'm writing an XML-REC client in PHP, ... First you can set a timeout in the context. ... And finally your web server will have its own timeout - check the documentation for whatever server you're using for details. ...
    (php.general)
  • Re: Script halts after 60 minutes
    ... Checked if php was running in safe mode, ... Does your server have a timeout value specified? ... Jerry Stuckle ... JDS Computer Training Corp. ...
    (comp.lang.php)
  • Re: Script halts after 60 minutes
    ... Checked if php was running in safe mode, ... Does your server have a timeout value specified? ... JDS Computer Training Corp. ... It looks like you're running PHP as a CGI, ...
    (comp.lang.php)
  • Re: Script halts after 60 minutes
    ... Checked if php was running in safe mode, ... Does your server have a timeout value specified? ... Jerry Stuckle ... JDS Computer Training Corp. ...
    (comp.lang.php)
  • Re: WebServer on WinCE
    ... As long as the web server itself is running your COM object in its thread, ... > I have a question on the CE Webserver. ... If I have a ASP page with a VB ... > client because of some timeout it hits. ...
    (microsoft.public.windowsce.app.development)