July 12, 2014    


 

 


This problem seems to be a result of the proliferation of mobile devices. And I don’t even have that many – only three that can receive email.

The problem occurs when you attempt to download email to a mobile device via wireless connection from your own IMAP email server. Either nothing happens and you get no error messages, or you get an error indicating that the server is busy. The exact error you receive will depend upon the programming of the mobile devices you are using. My iPhone just said the server was busy and to check the connection settings. K-9 Mail on my Kindle Fire HDX tablet just acts like it is working and ignores the problem.

And it is inconsistent. Sometimes one of the usually failing mobile devices will work and receive emails for a few minutes.

I never seem to experience this problem using Thunderbird, the Open Source email program.

Explanation

The issue is with the xinetd daemon configuration.

The xinetd daemon is the TCPWrapper daemon that manages services that do not really run as daemons, such as FTP, IMAP and POP. The xinetd daemon starts an instance for each of these services when a connection comes in on the port for that service.

The default number of connections that can be allowed for any service connecting from a single IP Address through xinetd is specified as 10 in the /etc/xinetd.conf configuration file. This appears to be not enough in cases like mine.

Each email client can make multiple IMAP connections to the server as it scans folders and downloads email.

Another aspect to this problem is that all of my mobile devices connect through the same wireless router. Thus they all appear to be originating with the single IP Address of the WAN side of the router that is connected to my internal network. The netstat command showed as many as 80 or 90 IMAP connections from that one IP address. Clearly the default of 10 is not enough.

Note that Thunderbird connections from different hosts inside my network each come from a different IP address so do not run afoul of the default maximum.

Solution

It is not a good idea to change the default number of connections in /etc/xinetd.conf as that applies to all services, not just IMAP.

Add the “per_source = 75” line as shown below, in the /etc/xinetd.d/imap configuration file. I used 75 as a number that seems to work well for me and which does not restrict the ability of any of our devices to download email. It is also neither “unlimited” – an allowable but not recommended option – nor so large that it is effectively the same as unlimited.


 

# default: off
# description: The IMAP service allows remote users to access their mail using \
#              an IMAP client such as Mutt, Pine, fetchmail, or Netscape \
#              Communicator.
service imap
{
disable = no
socket_type             = stream
wait                    = no
user                    = root
server                  = /usr/sbin/imapd
per_source            = 75
log_on_success  += HOST DURATION
log_on_failure  += HOST
}


 

You should set the number of connections to a value that makes sense for your environment.

Commentary

Well, I always have to have an opinion about things and this is no different.

A bit of experimentation shows that Thunderbird opens several connections which is considerably fewer than the observed 25 to 45 opened by various email apps on our mobile devices. So, although I believe that the Thunderbird program code has become quite bloated, it appears to be fairly well constrained when opening IMAP connections to an email server.