Я использую компонент Chilkat с php. Приложение является многопоточным, открыто около 10000 потоков.
Общий init imap:
$this->imap->put_Ssl(true);
$this->imap->put_PeekMode(true);
$this->imap->put_Utf8(true);
Это код подключения imap через HTTPS:
$this->imap->put_HttpProxyHostname($proxy->ip);
$this->imap->put_HttpProxyPort($proxy->port);
$this->imap->put_HttpProxyPassword($proxy->password);
$this->imap->put_ConnectTimeout(10);
$this->imap->put_ReadTimeout(10);
$isConnected = $this->imap->Connect($imap_server);
$loginAccount = $this->imap->Login($account->email, $account->password);
Следующее код для подключения к imap через туннель s sh:
$this->tunnel = new CkSocket();
$connectToSsh = false;
$authenticateSsh = false;
$sshOpenTunnelTask = $this->tunnel->SshOpenTunnelAsync($proxy->ip, $proxy->port);
if($sshOpenTunnelTask instanceof CkTask) {
$sshOpenTunnelTask->run();
$sshOpenTunnelTask->Wait(10000);
$connectToSsh = $sshOpenTunnelTask->GetResultBool();
if ($connectToSsh) {
$sshAuthenticateTask = $this->tunnel->SshAuthenticatePwAsync($proxy->username, $proxy->password);
$sshAuthenticateTask->Run();
$sshAuthenticateTask->Wait(10000);
$authenticateSsh = $sshAuthenticateTask->GetResultBool();
if (!$authenticateSsh) {
$sshOpenTunnelTask->Cancel();
$sshAuthenticateTask->Cancel();
}
} else {
$sshOpenTunnelTask->Cancel();
}
}
if($isConnected = $connectToSsh && $authenticateSsh) {
if($this->imap->UseSshTunnel($this->tunnel)) {
if($this->imap->Connect($account->imap_server)){
$loginAccount = $this->imap->Login($account->email, $account->password);
}
}
}
И проблема в том, что я столкнулся со следующими типами ошибок:
Для прокси-соединения https:
ChilkatLog:
Login:
DllDate: May 11 2019
ChilkatVersion: 9.5.0.78
Architecture: Little Endian; 64-bit
Language: Linux PHP
VerboseLogging: 0
loginX:
greeting: * OK [CAPABILITY IMAP4rev1 UIDPLUS NAMESPACE QUOTA CHILDREN SORT STARTTLS AUTH=CRAM-MD5 AUTH=DIGEST-MD5 AUTH=PLAIN] Dovecot ready.
authenticateLogin:
loginImap:
ConnectionType: Unencrypted TCP/IP
getCompleteResponse:
getImapResponseLine: Socket operation timeout.
Failed to get next response line from IMAP server.
--getCompleteResponse
--loginImap
--authenticateLogin
--loginX
Failed.
--Login
--ChilkatLog
А для соединения через туннель s sh:
ChilkatLog:
Login:
DllDate: May 11 2019
ChilkatVersion: 9.5.0.78
Architecture: Little Endian; 64-bit
Language: Linux PHP
VerboseLogging: 0
loginX:
greeting: * OK [CAPABILITY IMAP4rev1 UIDPLUS NAMESPACE QUOTA CHILDREN SORT STARTTLS AUTH=CRAM-MD5 AUTH=DIGEST-MD5 AUTH=PLAIN] Dovecot ready.
authenticateLogin:
loginImap:
ConnectionType: TCP inside SSH Tunnel
getCompleteResponse:
Socket recv failed.
Failed to receive more bytes.
Failed to get next response line from IMAP server.
--getCompleteResponse
--loginImap
--authenticateLogin
--loginX
Failed.
--Login
--ChilkatLog
Что может быть причиной этого:?
getImapResponseLine: Socket operation timeout.
Failed to get next response line from IMAP server.
и этого:?
Socket recv failed.
Failed to receive more bytes.
Failed to get next response line from IMAP server.
Приложение работает в Ubuntu 18.04. Вот важные конфигурации Ubuntu:
/ etc / sysctl.conf:
fs.file-max = 65535
vm.swappiness = 20
net.ipv4.conf.all.accept_redirects = 0
net.ipv4.conf.all.secure_redirects = 0
net.ipv4.conf.all.send_redirects = 0
net.ipv4.tcp_max_orphans = 65536
net.ipv4.tcp_fin_timeout = 10
net.ipv4.tcp_keepalive_time = 1800
net.ipv4.tcp_keepalive_intvl = 15
net.ipv4.tcp_keepalive_probes = 5
net.ipv4.tcp_max_syn_backlog = 4096
net.ipv4.tcp_synack_retries = 1
net.ipv4.tcp_mem = 50576 64768 98152
net.ipv4.tcp_rmem = 4096 87380 16777216
net.ipv4.tcp_wmem = 4096 65536 16777216
net.ipv4.tcp_orphan_retries = 0
net.ipv4.tcp_syncookies = 0
net.ipv4.netfilter.ip_conntrack_max = 16777216
net.netfilter.nf_conntrack_max = 16777216
net.ipv4.tcp_timestamps = 1
net.ipv4.tcp_sack = 1
net.ipv4.tcp_congestion_control = htcp
net.ipv4.tcp_no_metrics_save = 1
net.ipv4.route.flush = 1
net.ipv4.conf.all.rp_filter = 1
net.ipv4.conf.lo.rp_filter = 1
net.ipv4.conf.eth0.rp_filter = 1
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.all.accept_source_route = 0
net.ipv4.conf.lo.accept_source_route = 0
net.ipv4.conf.eth0.accept_source_route = 0
net.ipv4.conf.default.accept_source_route = 0
net.ipv4.ip_local_port_range = 1024 65535
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_window_scaling = 1
net.ipv4.tcp_rfc1337 = 1
net.ipv4.ip_forward = 0
net.ipv4.icmp_echo_ignore_broadcasts = 1
net.ipv4.icmp_echo_ignore_all = 1
net.ipv4.icmp_ignore_bogus_error_responses = 1
net.core.somaxconn = 65535
net.core.netdev_max_backlog = 1000
net.core.rmem_default = 65536
net.core.wmem_default = 65536
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
fs.inotify.max_user_watches = 16777216
И для файлов:
- soft nofile 20000
- hard nofile 20000
ВАЖНО: я заметил эту проблему только для определенного сервера imap