Subject: | SSL connections hang forever |
Date: | Wed, 8 Nov 2017 18:39:37 +0100 |
To: | bug-Net-IMAP-Simple [...] rt.cpan.org |
From: | Jörn Heissler <cpanbugs2017 [...] wulf.eu.org> |
Hello,
I'm using OTRS and it tries to fetch mails from an IMAPS (port 993)
account. It uses Net:IMAP:Simple for this task.
Sometimes the process hangs forever. From what I can see, the TLS socket
is running in blocking mode and a read() system call hangs, while imap
protocol messages are sent and received, i.e. the TLS connection itself
was established already.
I'm not entirely sure which module is at fault here, Net:IMAP:Simple or
IO::Socket::SSL.
My assumption is that Net:IMAP:Simple should use non-blocking sockets
and handle timeouts itself.
I don't have a full test case, but I found I can reproduce this by
abusing iptables:
iptables -A INPUT -s <imapserveraddress> -p tcp --sport 993 -m length 100:200 -j DROP
Stack trace:
/opt/otrs/bin/otrs.Daemon.pl:138
/opt/otrs/bin/otrs.Daemon.pl:316
/opt/otrs/bin/otrs.Daemon.pl:316
/opt/otrs/Kernel/System/Daemon/DaemonModules/SchedulerTaskWorker.pm:253
/opt/otrs/Kernel/System/Daemon/DaemonModules/SchedulerTaskWorker/Cron.pm:129
/opt/otrs/Kernel/System/Daemon/DaemonModules/SchedulerTaskWorker/Cron.pm:150
/opt/otrs/Kernel/System/Console/BaseCommand.pm:454
/opt/otrs/Kernel/System/Console/BaseCommand.pm:460
/opt/otrs/Kernel/System/Console/Command/Maint/PostMaster/MailAccountFetch.pm:94
/opt/otrs/Kernel/System/MailAccount.pm:440
/opt/otrs/Kernel/System/MailAccount/IMAP.pm:86
/opt/otrs/Kernel/System/MailAccount/IMAP.pm:257
/opt/otrs/Kernel/cpan-lib/Net/IMAP/Simple.pm:1021
/opt/otrs/Kernel/cpan-lib/Net/IMAP/Simple.pm:1210 while ( $res = $sock->getline ) {
/usr/share/perl5/IO/Socket/SSL.pm:2043 sub getline
OS: Ubuntu 16.04
Perl: 5.22.1
IO::Socket::SSL: 2.024
Net::IMAP::Simple: 1.2206
Best regards
Joern Heissler