hanging connections

Gábor Melis mega at retes.hu
Fri Feb 25 21:23:07 GMT 2011


> I'll try without autorefresh.

I did, but it didn't change a thing.

In the end it seems to be cured by:
  
diff --git a/offlineimap/imaplibutil.py b/offlineimap/imaplibutil.py
index cf82996..e27243f 100644
--- a/offlineimap/imaplibutil.py
+++ b/offlineimap/imaplibutil.py
@@ -111,6 +111,8 @@ class WrappedIMAP4_SSL(IMAP4_SSL):
             # FIXME
             raise socket.error(last_error)
 
+        self.sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1)
+
         #connected to socket, now wrap it in SSL
         try:
             if self._cacertfile:
	Modified offlineimap/init.py

and

sysctl -w net.ipv4.tcp_keepalive_time=15 \
          net.ipv4.tcp_keepalive_intvl=15 \
          net.ipv4.tcp_keepalive_probes=20

15s is pretty extreme I think. It has been going working fine for
several hours now with the original config, with autorefresh, two
accounts, four threads each.

I was going to say that this tells me is that one probably needs a
timeout parameter only to realize that there is one named socktimeout.
Bah. I haven't tested it yet, maybe a sensible default value is in
order.

Anyway, setting the SO_KEEPALIVE should not hurt, right?




More information about the OfflineIMAP-project mailing list