[imapfilter-devel] IDLE and 'connection reset by peer'

david mirabito david.mirabito at gmail.com
Mon Jan 18 04:01:38 EET 2010


Hi,

I just found imapfilter today and it looks ideal to replace an instance of thunderbird whose sole purpose is to filter my inbox for the various laptops/phones/ipods which access my account.

My script is quite simple, i use idle and loop in the script to avoid polling:


while true do
        okl.INBOX:check_status()

        -- exchange servers dont seem to like the contain_from() method .. fake with contain_field 
        okl.INBOX:contain_field("From","mothra"):move_messages(okl['Work/Mothra']) 
        okl.INBOX:contain_subject("Review Request"):move_messages(okl['Work/SDLC/ReviewBoard']) 
        okl.INBOX:contain_subject("[SDLC] branch create"):move_messages(okl['Work/SDLC/BranchCreate']) 
        okl.INBOX:contain_to("dri-patches at lists.sourceforge.net"):move_messages(okl['Lists/NV']) 
	<snip, but more of the same, really>

        res = okl.INBOX:enter_idle()
end

It seems to work fine, with updates coming in and emails instantly being moved to their proper home.

Only, after 5-10 minutes it seems to reliably crash out with:

imapfilter: reading data; error:00000000:lib(0):func(0):reason(0)

An strace shows:

write(3, "sending command (4):\n\n100C IDLE\r\n"..., 34) = 34
select(5, NULL, [4], NULL, NULL)        = 1 (out [4])
write(4, "\27\3\1\0 \214\370\374m\325\340\244\230\353\335\373;\237\27\274\332\371\v\253z\274q\305\265\301u\207~"..., 74) = 74
select(5, [4], NULL, NULL, NULL)        = 1 (in [4])
read(4, "\27\3\1\0@"..., 5)             = 5
read(4, "\240\2561\236\321:\331\342\353\212%[\230\31\303\352\210\221\206\2729eo\360)\365ZW\344\210~\363\352"..., 64) = 64
write(3, "getting response (4):\n\n"..., 23) = 23
write(3, "+ IDLE accepted, awaiting DONE co"..., 42) = 42
select(5, [4], NULL, NULL, {1740, 0})   = 1 (in [4], left {1438, 980000})
read(4, 0x80c1330, 5)                   = -1 ECONNRESET (Connection reset by peer)
write(2, "imapfilter: "..., 12)         = 12
write(2, "reading data; error:00000000:lib("..., 54) = 54
write(4, "\25\3\1\0 \20\244\0038bi\2\313_\304\245(O\245tjdj\214\311\240\25\1{\270\313#\233"..., 37) = -1 EPIPE (Broken pipe)
--- SIGPIPE (Broken pipe) @ 0 (0) ---
+++ killed by SIGPIPE +++

So for some reason my server is disconnecting me after 6 minutes or so. Email is an outsourced exchange server so I can't do too much serverside - but is there something I could investigate locally, or some way to recover from the dropped connection and try again?

I think at the least it would be nice if this error could be caught and returned to lua for handling.

Thanks,
  - David



More information about the Imapfilter-devel mailing list