imap problem

barts

Verified User
Joined
Nov 22, 2005
Messages
29
Hi,
i have problem with imap on CentOS6.x64, PHP5.3 (mod_php) + mod_ruid2.

I have imap compiled. Function imap_open() works from console (php script.php) but not from apache (2.4.4).

The same script from console show good results but from http://webserver/script.php doesn't:

Warning: imap_open(): Couldn't open stream {webserver:993/imap/ssl/novalidate-cert}INBOX in /home/user/domains/webserver/public_html/script.php on line 6 Array ( [0] => Unable to create selectable TCP socket (1938 >= 1024) )

Why?

rpm -qa|grep libc-client
libc-client-devel-2007e-11.el6.x86_64
libc-client-2007e-11.el6.i686
libc-client-2007e-11.el6.x86_64


PHP '--with-imap=/usr/lib/dovecot/imap' '--with-imap-ssl'
 
i don't have firewall (empty iptables).
Apache error_log is empty.
 
Yes, i know. i checked this file and it's empty. i don't save php errors to error_log.
PHP errors are in first post.
 
Im not a programmer, so im just guessing on what i actually may help.

Ive searched this error on google and apparently it happend when you try to create a server socket instead of a client socket, may be this the case?

Also in this forum there is something similar: http://forum.directadmin.com/showthread.php?t=40939 but the user didnt post the solution

Also, check if server is actually listening on 993 using netstat -ant | grep :993

Regards
 
I use PHP function imap_open():
<?php
$mbox = imap_open ("{webserver:993/imap/ssl/novalidate-cert}INBOX", "login", "pass");
print_r(imap_errors());
?>

so I don't create server/client socket.

Yes, my server is listening on 993. My script works from console, but not from web browser.
 
Yes, I tryed:

Warning: imap_open(): Couldn't open stream {localhost:993/imap/ssl/novalidate-cert}INBOX (Unable to create selectable TCP socket (1937 >= 1024)).
 
I've tried:
Couldn't open stream {localhost:143}INBOX
Unable to create selectable TCP socket (1937 >= 1024)
From console works.
 
Is there any possibility that you are somehow blocking connection or function with php.ini?

Have you tryed to rename you php.ini and restart apache just for a check?

Regards
 
I renamed php.ini, restarted apache and checked again. The same error: Unable to create selectable TCP socket (1937 >= 1024).
 
The issue must have been caused by a low FD_SETSIZE set in /usr/include/bits/typesizes.h and /usr/include/bits/posix_types.h. Instructions for increasing it can be found here: http://help.directadmin.com/item.php?id=9

UW-IMAP code, which throws the error is:
Code:
else if (sock >= FD_SETSIZE) {/* unselectable sockets are useless */
   sprintf (tmp,"Unable to create selectable TCP socket (%d >= %d)",
         sock,FD_SETSIZE);
 
The issue must have been caused by a low FD_SETSIZE set in /usr/include/bits/typesizes.h and /usr/include/bits/posix_types.h. Instructions for increasing it can be found here: http://help.directadmin.com/item.php?id=9

UW-IMAP code, which throws the error is:
Code:
else if (sock >= FD_SETSIZE) {/* unselectable sockets are useless */
   sprintf (tmp,"Unable to create selectable TCP socket (%d >= %d)",
         sock,FD_SETSIZE);

I am also getting the same error with php-imap, this is only happening on one of my servers:
Code:
[0] => Unable to create selectable TCP socket (1990 >= 1024)

In /usr/include/bits/typesizes.h I already have the high value:
Code:
#define	__FD_SETSIZE 32768

However in /usr/include/linux/posix_types.h I have only 1024:
Code:
#undef __FD_SETSIZE
#define __FD_SETSIZE	1024

So I changed /usr/include/linux/posix_types.h to be 32768:
Code:
#undef __FD_SETSIZE
#define __FD_SETSIZE 32768

Then I recompiled apache and php in custombuild, but still I get the same error when using php-imap:
Code:
[0] => Unable to create selectable TCP socket (1990 >= 1024)

I have installed php-imap with smtalk own script from here: http://forum.directadmin.com/showthread.php?t=45434&p=232384#post232384

Should I recompile/reinstall smtalk script in order for this to be solved? Or what else should I do?
 
The problem was solved by doing two things, I upped the limit in /usr/include/linux/posix_types.h as posted in previous reply, then I needed to reinstall uw-imap and php.
 
Back
Top