Search code examples
phpchilkat

PHP chilkat is taking a long time for some functions


I use php chilkat component and some functions sometimes require a long time.

imap->Disconnect(); maximum time detected - 60 seconds.

When I just do imap = null - it still required 60 seconds.

I guess when it is destructed, it also disconnects inside the chilkat component.

How can I prevent the long time of execution, because the application speed is bad.

Can I just kill the connection immediately ?

Why does this:

selectMailbox() - maximum time detected - 68 seconds.

takes so long?

closeMailbox() - 10 seconds.

I have set ReadTimeout = 2 but execution time was detected 5 seconds..

This is the code:

$time = microtime(true);

$this->imap->put_ReadTimeout(2);
$this->imap->Disconnect();
$this->imap = null;

var_dump(microtime(true) - $time);

Solution

  • If your IMAP server takes a long time to respond, then the IMAP client can't make the IMAP server respond any faster. Perhaps the IMAP server is overloaded at particular times..

    You can set the Imap.ReadTimeout property to a smaller value. The default value is 30 seconds. Let's say you set the ReadTimeout = 5. This will tell Chilkat to abandon the connection/session if the IMAP server does not send a response within 5 seconds. The good part is that your function will return after 5 seconds. The bad part is that your session will be lost and you'll need to re-connection, re-authenticate, and re-select the mailbox. Maybe this is OK for the call to Disconnect. It's probably not OK for the call to SelectMailbox.