2

I have a PHP script that sends a request to a web service via soap. I expect to get a response back in just a few seconds, but if I do not receive a response within 30 seconds I need to send another request voiding my first request.

Any suggestions on the best way to handle this timer feature? Should I be looking at PHP's set_time_limit setting? Looking for any insight or general ideas.

Thanks.

3
  • Trying to simplify this as much as possible. Could I simply put the first call on a page with a header refresh set to 30 seconds? If my script gets a response before then, I set my script to redirect to the next page I want. If no response after the 30 seconds, the header redirect can jump to the page with the void request? Commented Sep 25, 2009 at 2:37
  • You are speaking about stuff that happens in the client (headers) not on the server. Commented Sep 25, 2009 at 3:01
  • Look, this is a classic event driven programming. You need a listener and you need a caller. Both working/awake at the same time. Commented Sep 25, 2009 at 3:02

2 Answers 2

1

Found this on the web and seems like a step in the right direction...

a feature -> setting a connection timeout

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

Sign up to request clarification or add additional context in comments.

Comments

0

If we only had multi threading....
My approach (although you can do async calls with CURL) would be to write a script that manages this process. This script would do:

  1. Using shell/cron/async javascript (from the client side)/async call using CURL to activate the calling script.
  2. Check every few seconds if the calling script returned an answer (answer is saved to memory/disk by the calling script, which also serves as a flag->I finished)
  3. 30 seconds passed - kill the current instance of the calling script, instantiate another calling script.

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

1 Comment

Restored your -1 to zero. Legitimate answer. I would do it through Cron as well.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.