G
G
Grigory Vasilkov2017-03-10 12:21:01
PHP
Grigory Vasilkov, 2017-03-10 12:21:01

How to find out which PHP function goes into the "eternal request"?

I checked that all curls were closed, so that timeouts were everywhere.
But from time to time, a script whose task will go to google docs many times, then to the file system, then again to google_docs, then again to fs - goes into waiting until a 504 is received from nginx.
If you wait a minute and run - it will work.
Run it again - it will work again.
But from time to time, quite by accident, it will go into waiting.
How to understand where the script stopped to check what's wrong?
There are concerns about the operation of the write-read functions in the OS, because this bug periodically pops up when you work with uploads, where you also need to open a file, close the file, read, send ...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
Falseclock, 2017-03-10
@Falseclock

Just call an exception or make a handler for this code, after setting the timeout in seconds.

curl_setopt($ch, CURLOPT_TIMEOUT, 400); // время в секундах
// тут ваш код запрос страницы
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
          
if ($httpcode == 0) { throw new Exception("No connection"); }
if ($httpcode == 504) { throw new Exception("504 can't connect"); }

inside throw new Exception, you can display the URL that you requested in the error, or even display from where the legs grow from debug_backtrace.
If you want without an exception, then just write the logs somewhere

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question