DavMail and port binding problems

I have just moved from openSUSE 12.2 to 13.1 (clean install). I connect to an exchange server for work email and calendars, using Thunderbird and DavMail. Shortly after configuring, I noticed that upon reboot (or shutdown) and starting DavMail again it complains with the following port binding messages

Unable to bind server socket for SMTP on port 1025: port not allowed or in use by another process
Unable to bind server socket for POP on port 1110: port not allowed or in use by another process
Unable to bind server socket for IMAP on port 1143: port not allowed or in use by another process
Unable to bind server socket for CALDAV on port 1080: port not allowed or in use by another process
Unable to bind server socket for LDAP on port 1389: port not allowed or in use by another process

Through a bit of research and trial and error, I have found that I can release the ports manually with

fuser -k -n tcp 1025
fuser -k -n tcp 1110
fuser -k -n tcp 1143
fuser -k -n tcp 1080
fuser -k -n tcp 1389

then DavMail behaves as normal again. If I terminate DavMail and restart it behaves okay, as does suspend/resume. I think it may be related to systemd changes, but can’t be sure.

I’d be interested to know whether other DavMail gateway users are experiencing similar issues, or perhaps know of a possible fix or workaround…

Now that I’ve found to check further, I note that when davmail is running, there is an associated java process running (it is a java application after all). When the OS is rebooted, it appears that the application is not closed properly, and the result is that a java process is already alive before davmail is started,

ps -A|grep java
  861 ?        00:00:00 java

When it starts I then have

ps -A|grep java
  861 ?        00:00:00 java
 1574 ?        00:00:00 java

and the original process is bound to the ports


# netstat -lptu
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name   
tcp        0      0 localhost:webadmstart   *:*                     LISTEN      861/java            
tcp        0      0 localhost:imyx          *:*                     LISTEN      861/java            
tcp        0      0 localhost:socks         *:*                     LISTEN      861/java            
tcp        0      0 localhost:smtp          *:*                     LISTEN      872/master          
tcp        0      0 localhost:blackjack     *:*                     LISTEN      861/java            
tcp        0      0 localhost:iclpv-dm      *:*                     LISTEN      861/java

So, while I don’t yet have a solution, I now know the cause. :slight_smile: Something has clearly changed between openSUSE 12.2 and 13.1 with regards to the shutdown process. Maybe someone more knowledgeable than me can shed more light on this.

I have always started DavMail using /usr/bin/davmail via KDE Autostart. This has been what has traditionally been recommended. Now, I’m wondering if I should launch it as systemd service (but then it would be a system-wide server running silently in the background). Haven’t thought about the pros and cons of that…

Further investigation found the culprit: I had a look at the davmail RPM and found /etc/init.d/davmail (the script responsible for the java process). Now that I’ve removed it, all is well.

Nice find. Praise the logic in linux