O
O
Olegpc2018-09-04 18:51:19
PHP
Olegpc, 2018-09-04 18:51:19

Why doesn't the apache process terminate after connecting via IMAP?

Good afternoon.
Faced such a problem.
There are about 15 mailboxes on Yandex. Task: to collect new mail from these boxes every 5 minutes using the imap protocol in php.
In 40 percent of cases, the imap connection process fails with a timeout error.
And the process on apache remains hanging. It can hang for a very long time, or it can end after some time.
I can't figure out how to make the process kill if the connection is not established.
In this code

$listacc = "список всех почтовых ящиков";
foreach($listacc as $acc){
  if($acc['status'] == 1){
    $server = $acc['server'];
    $login = $acc['username'];
    $password = $acc['pass'];
    $user_id = $acc['user'];
    $result = Message::searchPostInMail($server, $login, $password, $user_id);
    if(!$result){
      die();
    }
  }
}
die();

Even if the function exits, the process hangs

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dedalqq, 2018-09-04
@dedalqq

When your browser download to your Apache timed out, it was at that moment that you lost the connection to the imap server. Do not look at Apache processes, they are almost unrelated to this, look at what ports you have open on this machine for outgoing connections. The Apache + php bundle works in such a way that as soon as the request to this Apache itself has ended (by timeout or no matter what else), as such, the php process (do not confuse it with the OS process) also finished its work, and as a result, all open resources ( in this case, the connection to imap) was closed. This has nothing to do with what you see in Apache processes in your OS

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question