[horde] Using Horde_Imap_Client_Socket, able to connect but no data is ever sent (always a "ERROR: read/timeout error")
Meitar
meitarm at gmail.com
Wed Aug 3 01:57:15 UTC 2016
Hi,
I’d like to use the Horde IMAP Client library (Horde_Imap_Client_Socket) in an application I’m developing, but I’m running into an issue that I can’t find a prior solution for described in the archives of this list or on Horde’s bug tracker. I’ve never used a Horde library before, so also apologies if there’s a better place to ask this.
The closet prior matching search result I’ve found in the archives here is this thread: https://lists.horde.org/archives/horde/Week-of-Mon-20140929/052726.html The proposed solution is to abandon TLS connections, which is not an option for me as I do not administer the IMAP server (and I wouldn’t want to sacrifice transport security anyway).
My issue seems to be that despite being able to connect to an IMAP server, no data is ever sent or received after the initial connection when trying to perform an IMAP `search()`. The debug log simply shows the following snippet whenever I try to do search():
------------------------------
>> Wed, 03 Aug 2016 01:10:30 +0000
>> Connection to: imap://my.imap-server.com:993/
>> Server connection took 0.6241 seconds.
>> Slow Command: 30.004 seconds
>> ERROR: read/timeout error.
------------------------------
I’ve tried this on multiple PHP versions with the same results, on both an Ubuntu and a Mac OS host.
* PHP 5.5.36 (cli)
* PHP 7.0.5 (fpm)
My Horde_Imap_Client was installed via Composer in both environments. Specifically, my composer.lock file reports versions:
"name": "pear-pear.horde.org/Horde_Imap_Client",
"version": “2.29.8”,
Further, I’ve been able to verify that the IMAP server itself is fine, and the account I’m trying to use is valid. An example interactive command-line session (account credentials redacted):
$ openssl s_client -connect my.imap-server.com:993 -quiet
[…SNIPPED FOR LENGTH…]
* OK [CAPABILITY IMAP4rev1 UIDPLUS CHILDREN NAMESPACE THREAD=ORDEREDSUBJECT THREAD=REFERENCES SORT QUOTA IDLE AUTH=PLAIN] Courier-IMAP ready. Copyright 1998-2008 Double Precision, Inc. See COPYING for distribution information.
a1 LOGIN me at my-domain.com [REDACTED]
a1 OK LOGIN Ok.
a2 LIST "INBOX" "*"
* LIST (\HasNoChildren) "." "INBOX.INBOX.Junk"
* LIST (\HasNoChildren) "." "INBOX.Archive"
* LIST (\HasNoChildren) "." "INBOX.old-messages"
* LIST (\HasNoChildren) "." "INBOX.Trash"
* LIST (\HasNoChildren) "." "INBOX.Sent"
* LIST (\HasNoChildren) "." "INBOX.Notes"
* LIST (\HasNoChildren) "." "INBOX.Drafts"
* LIST (\Noselect \HasChildren) "." "INBOX.INBOX"
a2 OK LIST completed
After reassuring myself that the server was functioning properly when contacted interactively via the command line, I performed a network packet capture using wireshark to see what traffic, if any, the Horde_Imap_Client library was transmitting. However, that’s when I saw it was basically empty. Here’s a `tshark` output snippet showing a successful TCP connection handshake, then a thirty-second hang, then a standard TCP teardown, with nothing in between:
22 210.145139 10.0.2.15 -> 69.163.253.7 TCP 74 45799 > imaps [SYN] Seq=0 Win=29200 Len=0 MSS=1460 SACK_PERM=1 TSval=6760562 TSecr=0 WS=128
23 210.295324 69.163.253.7 -> 10.0.2.15 TCP 60 imaps > 45799 [SYN, ACK] Seq=0 Ack=1 Win=65535 Len=0 MSS=1460
24 210.295365 10.0.2.15 -> 69.163.253.7 TCP 54 45799 > imaps [ACK] Seq=1 Ack=1 Win=29200 Len=0
24 25 240.381278 10.0.2.15 -> 69.163.253.7 TCP 54 45799 > imaps [FIN, ACK] Seq=1 Ack=1 Win=29200 Len=0
25 26 240.381459 69.163.253.7 -> 10.0.2.15 TCP 60 imaps > 45799 [ACK] Seq=1 Ack=2 Win=65535 Len=0
27 240.536303 69.163.253.7 -> 10.0.2.15 TCP 60 imaps > 45799 [FIN, ACK] Seq=1 Ack=2 Win=65535 Len=0
28 240.536331 10.0.2.15 -> 69.163.253.7 TCP 54 45799 > imaps [ACK] Seq=2 Ack=2 Win=29200 Len=0
28 ^C
If I understand correctly, this means that the IMAP library is able to create a connection but never actually receives or sends any data through it. The timeout error is originating from Horde_Imap_Client_Socket_Connection_Socket::read() on line 216, causing an uncaught exception described rather unhelpfully as "Error when communicating with the mail server.”
I’m baffled because as far as I can tell, I’m constructing the Horde_Imap_Client_Socket correctly, and none of my other mail clients have any trouble with the given settings.
Any advice or suggestions would be appreciated.
Thanks,
-Meitar Moscovitz
More information about the horde
mailing list