[PHP] XMLRPC and file_get_contents

2007-08-16 Thread Andreas Schlicker

Hi all,

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

 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?

Kind regards,
Andreas

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] XMLRPC and file_get_contents

2007-08-16 Thread Andreas Schlicker

Stut wrote:

Andreas Schlicker wrote:

Hi all,

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

 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

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] XML-RPC problem with long running times

2005-12-29 Thread Andreas Schlicker

Hi all,

I'm using Apache/1.3.33 (Unix), PHP/5.0.3, mod_ssl/2.8.22, OpenSSL/0.9.6a.

I wrote a dummy script that is called by a Java program via XML-RPC, 
waits for some time and replies the start and end times.




If the script sleeps for up to 5 minutes, it works perfectly fine. 
However, I my real application will run probably an hour or so. If the 
script takes more than 5 minutes to execute, the client receives an 
empty response, even the header is missing. If I try to write the 
$xmlResponse to a file, the client receives a null message.


I wrote a small script without XMLRPC that acted the same way when 
called by a browser. This worked perfectly (I tested it up to 20 minutes 
waiting time) even if I used set_time_limit(5) and sleep(500).


Does anybody have an idea how to solve this problem? Thanks in advance.

Andreas

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] XML-RPC problem with long running times

2005-12-29 Thread Andreas Schlicker

Of course, fflusch($log); should be fflush($log);

I just found out that $xmlResponse really is empty.
However, connection_status() returns 0, so I assume that the script is 
not interrupted by a timeout.


Why does xmlrpc_server_call_method($xmlServer, $xmlRequest, NULL) return 
nothing if the call takes longer than 5 minutes and there is no 
interrupt? Is there some "special" XMLRPC timeout?


Any idea?

Andreas


Andreas Schlicker schrieb:

Hi all,

I'm using Apache/1.3.33 (Unix), PHP/5.0.3, mod_ssl/2.8.22, OpenSSL/0.9.6a.

I wrote a dummy script that is called by a Java program via XML-RPC, 
waits for some time and replies the start and end times.




If the script sleeps for up to 5 minutes, it works perfectly fine. 
However, I my real application will run probably an hour or so. If the 
script takes more than 5 minutes to execute, the client receives an 
empty response, even the header is missing. If I try to write the 
$xmlResponse to a file, the client receives a null message.


I wrote a small script without XMLRPC that acted the same way when 
called by a browser. This worked perfectly (I tested it up to 20 minutes 
waiting time) even if I used set_time_limit(5) and sleep(500).


Does anybody have an idea how to solve this problem? Thanks in advance.

Andreas



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php