Web Service Call Timer

I have a PHP script that sends a request to a web service via a soap. I expect to receive a response in a few seconds, but if I don't receive a response within 30 seconds, I need to send another request canceling my first request.

Any suggestions on the best way to handle this timer function? Should I be looking at the PHP _time

_limit set ? Look for any ideas or general ideas.

Thank.

+2


source to share


2 answers


Discovered this online and seems like a step in the right direction ...

function -> set connection timeout



$ client = new SoapClient ($ wsdl, array ("connection_timeout" => 5)); The connection_timeout parameter specifies the timeout, in seconds, for connecting to the SOAP service. This parameter does not define a timeout for services with slow responses. To limit the timeout for calls to complete setting default_socket_timeout is available.

+1


source


If we only had multithreading ....
My approach (although you can make asynchronous calls from CURL) was to write a script that manages this process. This script will do:

  • Using shell / cron / async javascript (client side) / asynchronous call using CURL to activate the calling script.
  • Check every few seconds if the calling script returns a response (the response is saved in memory / disk by the calling script, which also serves as a flag -> I'm done)
  • It took 30 seconds - kill the current instance of the calling script, instantiate another call to the script.


This is a very crude description and finer details should be better defined.

0


source







All Articles