Long PHP SOAP process
I've been working on a website that get all its data through SOAP. Some pages may have three or four calls to the soap server and some of the calls can sometimes take quite long (30-60 seconds).
What I've noticed happening is if I interrupt the request during one of the long 30 second calls (stop the browser loading) and issue another request to a call that doesn't take very long (load another URL with shorter calls) I don't get a request until the 30 seconds of the initial call are up (or so it seems).
What exactly is happening here and is there a way around it?
I开发者_运维百科s this something pcntl could help mitigate? Also I'm looking to set up PHP with FPM through Nginx. Will this affect things?Thanking all!
I suspect that if you sniff the traffic at both ends (e.g. with wireshark) then the answer may be a lot clearer.
My guess would be that either the client or server is trying to do a DNS lookup which is very slow. Usually very slow DNS lookups occur for non-existent records - and since the request is landing at the server, it implies that the failed DNS lookup is being done by the server on the client IP address.
(I think) I had had a similar problem. I was using SOAP to receive requests on the PHP side from a Java server (This was sending the requests).
A question for you, Do you have to send an ACK (acknowledgement) response back? If yes I think your requests are timing out.
Here is what happened to me:
On the Java side it expected a ACK response in under 30 seconds or an error would occur and it would resend the request.
On the PHP side, even though I sent the ACK response as soon as I got the SOAP request, PHP won't send it till the end of the script execution. This is due to PHP being a Single Thread Language.
What I did to get around this was to accept the SOAP request, Parse it into a DB and send back the ACK response. Then kick off another script (daemon) to process the SOAP request. It is a hack to get around what my issue was.
Hope this might shed some light into your problem.
BTW this was for Salesforce (The Java side of things) and their PHP Tool kit (API)
精彩评论