Summary:ASTERISK-10620: IMAP client fails with: IMAP Error: Unable to create selectable TCP socket (1024 >= 1024)
Reporter:Yehavi Bourvine (yehavi)Labels:
Date Opened:2007-10-25 15:08:22Date Closed:2007-12-19 13:26:51.000-0600
Versions:Frequency of
Environment:Attachments:( 0) imap.log.gz
( 1) test.txt
Description:Trying to set Asterisk to use IMAP as mail storage using Dovecot as the server fails with the above error.

After Asterisk starts all works ok; however, after a few minutes the above error is given and then voicemail cannot access the messages store.

A fragment from the log is attached.


Patches applied:
8824 for remote party ID.
App_voicemail.c has been changed slightly to change the prompts for Hebrew
  (will be published when done).

Imap library used is imap2006-j, dated 4-April-2007 (so says the README file).
Comments:By: Mark Michelson (mmichelson) 2007-10-31 11:24:26

Hmm, based on the messages in test.txt, it appears that something is configured incorrectly with dovecot. Unfortunately, I'm not familiar enough with dovecot to know which setting is causing the security problem.

What I'm guessing is happening is that each attempt to open a mailbox is causing a socket to be created, and after 1024 have been reached, you get that error. I have a strong suspicion that if you can get that "insecure server advertised AUTH/PLAIN" to go away, then this other issue would disappear as well. Possibly there's an incompatibility between the c-client and dovecot's auth schemes? Perhaps one or both needs to be recompiled with SSL support?

By: Yehavi Bourvine (yehavi) 2007-11-01 06:32:22

The message about "insecure server..." means that the server is willing to accept plain text passwords over a regular TCP connection (port 143) and is not using SSL for it. It is only a warnning (I looked in the Imap source code).

So it doesn't seem to be related (to my understanding).

I am willing to add debugging code, just say what and where...

                       Thanks, __Yehavi:

By: Mark Michelson (mmichelson) 2007-11-01 12:27:43

Okay, thanks for the explanation.

I think the next step in diagnosing this will be to see what debug messages asterisk prints during all this. Set your debug level to at least 4 in app_voicemail

CLI> core set debug 4 app_voicemail.c

Also, make sure that logger.conf is set to log debug messages. Then just upload the output. It'll be a lot more than what you've seen so far and hopefully will give some more insight into why this error is happening.

By: Yehavi Bourvine (yehavi) 2007-11-01 13:10:07

I'll run a debug session during the weekend.


By: Yehavi Bourvine (yehavi) 2007-11-06 23:25:27.000-0600

I have a log which demonstrates the problem and is 10MB large. I cannot upload it (get an error message) so I placed it for FTP at:
ftp://e99994878KK:7IEkKy2p@tethys.cc.huji.ac.il  (look for imap.log)

Can someone please upload it?

BTW, how can I generate such a log without the  ANSI escape sequences?

One more thing to note: ulimit for file descriptors is 1024. I did not raise it in order for the problem to appear within 10 minutes. I guess that if I incerease it the problem will appear later.

                     Thanks! __Yehavi:

By: Mark Michelson (mmichelson) 2007-11-15 15:05:11.000-0600

I attempted looking at that link you provided but got an error.

"530: login authentication failed"

By: Yehavi Bourvine (yehavi) 2007-11-15 23:01:38.000-0600

I've GZIPed it and uploaded it.

                    Thanks! __Yehavi:

By: Yehavi Bourvine (yehavi) 2007-12-19 05:48:38.000-0600

After a long time (hard to take down a production system) I had success with IMAP. The above error has been dismissed after using imap2007k instead of a previous version.

One new caveat: If a user is defined on Asterisk but not on the IMAP server, Asterisk starts working very slowly; CPU is free, but Asterisk is delaying every action, sometimes up to tens of seconds.

And another possible future problem: Asterisk ceates a separate IMAP connection for each user. Today I have a few dosens of them; what will happen when I have thousands of users?

                            Thanks! __Yehavi:

By: Mark Michelson (mmichelson) 2007-12-19 13:26:51.000-0600

I'm glad you were able to get your problem fixed.

Regarding your other concerns:

Since we're using the IMAP c-client to handle connections, we can't control how it manages sockets. So in other words, we can't really do anything about the fact that a different connection is used for every user.

I would guess that the problem with Asterisk running very slowly has to do with timeouts in either the c-client or in your IMAP server. These timeouts may be configurable, so I would search for options having to do with that.