[Twisted-web] livepage connection "timing out"/dying randomly

Robby Dermody robbyd at u20.org
Thu Oct 27 11:50:17 MDT 2005


Hey guys,

I seem to have a problem with client browsers to my guarded livepage 
application loosing their livepage connections. It seems that the guard 
session doesn’t expire, but the livepage system on the server side seems 
like it will loose track of the client’s nevow handle. This is under the 
Nevow 0.5.0 release, and it happens under both IE 6.0.x and Firefox 1.0.x.

Basically, my server app makes livepage calls to the client browser js 
via clientHandle.call() to reflect dynamically updated data as it 
happens… (maybe one call every 4 seconds). At this point I found this 
problem (that at some point these updates in the client would stop, 
while the server was still making the livepage call() invocations like 
everything was fine and dandy). The problem was that things just seemed 
to die, and I could find no error output showing why.

Well, in my search for a fix/error output, I added a js function on the 
client that calls server.handle('refreshSession()') every 120 seconds 
via the use of repeated setTimeout() calls. The corresponding 
handle_refreshSession() function on the server gets that client's 
session object and touch()es it.

This will start out working fine for usually a few hours (the session 
timeout is 1200 seconds currently), and the client will stay logged in. 
Then after some seemingly arbitrary amount of time, I will start getting 
the following errors, one set for each refreshSession() call:

 From the client side (firefox java console):

Error: syntax error
Source File: http://216.148.216.20:8800/mon/nevow_glue.js
Line: 155
Source Code:
<html><head><title>Exception</title></head><body><style type="text/css">

 From a glance at nevow_glue.js, it looks like the server returned an 
exception page to the client and nevow_clientToServerEvent() in 
nevow_glue.js didn’t like that when it tried to evaluate it as 
javascript code, or some kind of javascript result.

On the server side I get the following python exception:

---**** EXCEPTION START ****---
Traceback (most recent call last):
   File "/usr/lib/python2.4/site-packages/twisted/internet/defer.py", 
line 216, in addCallback
     callbackKeywords=kw)
   File "/usr/lib/python2.4/site-packages/twisted/internet/defer.py", 
line 207, in addCallbacks
     self._runCallbacks()
   File "/usr/lib/python2.4/site-packages/twisted/internet/defer.py", 
line 328, in _runCallbacks
     self.result = callback(self.result, *args, **kw)
   File "/usr/lib/python2.4/site-packages/nevow/appserver.py", line 308, 
in handleSegment
     return defer.maybeDeferred(
--- <exception caught here> ---
   File "/usr/lib/python2.4/site-packages/twisted/internet/defer.py", 
line 117, in maybeDeferred
     result = f(*args, **kw)
   File "/usr/lib/python2.4/site-packages/nevow/livepage.py", line 596, 
in locateChild
     client = self.clientFactory.clientHandles[handleId]
exceptions.KeyError: '2'

---****  EXCEPTION END  ****---

In this case, the key ‘2’ was the setting of the client’s 
“nevow_clientHandleID” variable. This will happen every time the client 
tries to make the call (e.g. every 120 seconds).

I think these two types of updates I’m doing (one where the server tries 
to call a js method on the client when its data is updated, and one 
where the client periodically “pings” the server) are both exposing the 
same error. The only difference is that the one where the client pings 
the server with the server.handle() call exposes some error messages of 
what may be going wrong.

Might I be forgetting to do something, or using livepage improperly? My 
goal is to make it so that, as long as a client’s browser is logged in 
and at my page, they will keep getting livepage events indefinitely.

Might the newest version from the repository fix this?


Thanks for any help,

Robby



More information about the Twisted-web mailing list