Reputation: 336
We use the following code to connect to IMAP via SSL:
imap_timeout(IMAP_OPENTIMEOUT, 5);
imap_timeout(IMAP_READTIMEOUT, 5);
imap_timeout(IMAP_WRITETIMEOUT, 5);
imap_timeout(IMAP_CLOSETIMEOUT, 5);
$connection = null;
try {
$connection = imap_open('{'.$host.':'.$port.'/service='.$service.$crypt.'/novalidate-cert}', $user, $pass, OP_SILENT, 1, array('DISABLE_AUTHENTICATOR' => 'PLAIN'));
} catch (Exception $e) {
// Errors logged in a summary below
}
This works often without any issue. However, sometimes it hangs on imap_open for more than 800s. The error it returns is:
TLS\/SSL failure for imap.xxx.net: SSL negotiation failed
How can I make sure imap_open does not wait so long?
Upvotes: 0
Views: 1499
Reputation: 11
This problem is extremely ugly and depending on the operating system, there is no reasonable solution.
Different workaround like ini_set('default_socket_timeout', 5);
depend
I think the only sustainable solution is the fix in the appropriate library. Since PHP is now organized in Github, I have resubmitted this issue there in the hope that we can find a way to fix this old problem in a sustainable way.
https://github.com/php/php-src/issues/17510
Upvotes: 1