Dieter Maurer wrote:
Paul Winkler wrote at 2005-11-28 15:37 -0500:
...
We had to implement a keep alive mechanism to prevent our firewall from behaving in this nasty way.
OK. Can you give a high-level summary of what you did? I thought of using heartbeat to detect loss of connection, but I'm not sure what I could do on failure short of restarting Zope.
We knew that our firewall shuts down connections with a timeout of 30 min. Thus, we have send our ZEO a keep alive message every 20 min. The code roughly looks like this:
KeepPeriod= int(environ.get('ZEO_KEEP_ALIVE')) * 60
Storage = getConfiguration().dbtab.getDatabase('/')._storage
def keepAlive(): LOG("CustomZODB",INFO,"Keep alive thread started") while 1: sleep(KeepPeriod) if Storage._ready.isSet(): LOG("CustomZODB",INFO,"Sending keep alive message") Storage._load_lock.acquire() try: try: Storage._server.get_info() LOG("CustomZODB",INFO,"Sent keep alive message") except: LOG("CustomZODB",ERROR,".... failed", error=exc_info()) finally: Storage._load_lock.release() else: LOG("CustomZODB",PROBLEM,"Connection is down") start_new_thread(keepAlive,())
Why not use the max-disconnect-poll option of the zeoclient section in zope.conf ? Florent -- Florent Guillaume, Nuxeo (Paris, France) Director of R&D +33 1 40 33 71 59 http://nuxeo.com fg@nuxeo.com