Using unique comet streams per page

63 views
Skip to first unread message

Joseph Shraibman

unread,
Apr 27, 2012, 12:23:28 PM4/27/12
to liftweb
I'm running into a problem with pages that use comet actors.  When I reload the page it seems that the browser connects to the comet stream attached to the old page, which results in errors since variables from the old page don't exist in the rerendered page.  When this happens I have to clear my cookies and reload again (or restart the webapp).  Is there any way to ensure unique comet streams per page render?

Diego Medina

unread,
Apr 27, 2012, 12:34:32 PM4/27/12
to lif...@googlegroups.com
Could you be a bit more specific?

Are you accessing different versions of the same url, as in:


http://host/item?p=1

and
http://host/item?p=2

?

Maybe putting together a sample app [1] will help us see what you see,
and help you better
Or maybe you need this
http://blog.fmpwizard.com/lift-comet-actor-per-tab-library


[1] https://www.assembla.com/wiki/show/liftweb/Posting_example_code

Regards,

Diego
> --
> Lift, the simply functional web framework: http://liftweb.net
> Code: http://github.com/lift
> Discussion: http://groups.google.com/group/liftweb
> Stuck? Help us help you:
> https://www.assembla.com/wiki/show/liftweb/Posting_example_code



--
Diego Medina
Lift/Scala Developer
di...@fmpwizard.com
http://www.fmpwizard.com

David Pollak

unread,
Apr 27, 2012, 12:56:34 PM4/27/12
to lif...@googlegroups.com
On Fri, Apr 27, 2012 at 9:23 AM, Joseph Shraibman <josep...@gmail.com> wrote:
I'm running into a problem with pages that use comet actors.  When I reload the page it seems that the browser connects to the comet stream attached to the old page, which results in errors since variables from the old page don't exist in the rerendered page.  When this happens I have to clear my cookies and reload again (or restart the webapp).  Is there any way to ensure unique comet streams per page render?

By default, the same CometActor is used for the entirety of a session.  If you want to use a different CometActor each time you load the page, please override def lifespan = Full(3 seconds) and when you invoke the CometActor:  <div data-lift="comet?type=Foo&randomname=true"></div>
 

--
Lift, the simply functional web framework: http://liftweb.net
Code: http://github.com/lift
Discussion: http://groups.google.com/group/liftweb
Stuck? Help us help you: https://www.assembla.com/wiki/show/liftweb/Posting_example_code



--
Visi.Pro, Cloud Computing for the Rest of Us http://visi.pro
Lift, the simply functional web framework http://liftweb.net

Joseph Shraibman

unread,
Apr 27, 2012, 1:51:43 PM4/27/12
to lif...@googlegroups.com


On Fri, Apr 27, 2012 at 12:34 PM, Diego Medina <di...@fmpwizard.com> wrote:
Could you be a bit more specific?

Are you accessing different versions of the same url, as in:

It's the same url.  I generate unique ids in my css transforms so the element names are different each time I reload the page.

Joseph Shraibman

unread,
Apr 27, 2012, 2:05:10 PM4/27/12
to lif...@googlegroups.com


On Fri, Apr 27, 2012 at 12:56 PM, David Pollak <feeder.of...@gmail.com> wrote:
 when you invoke the CometActor:  <div data-lift="comet?type=Foo&randomname=true"></div>



Thanks.  AFAICT that did the trick, but I'm not 100% sure I'm testing properly.

Antonio Salazar Cardozo

unread,
Apr 27, 2012, 2:11:21 PM4/27/12
to lif...@googlegroups.com
Whoa, where did the randomname parameter come from? I didn't know that was there! It's almost a year old!

Time to rip some code out :p
Thanks,
Antonio

Diego Medina

unread,
Apr 27, 2012, 2:17:36 PM4/27/12
to lif...@googlegroups.com
On Fri, Apr 27, 2012 at 2:11 PM, Antonio Salazar Cardozo
<savedf...@gmail.com> wrote:
> Whoa, where did the randomname parameter come from? I didn't know that was
> there! It's almost a year old!
>

And as soon as we get 2.5 API builds, it will be on the scaladocs :)

Diego

David Pollak

unread,
Apr 27, 2012, 3:24:23 PM4/27/12
to lif...@googlegroups.com
On Fri, Apr 27, 2012 at 11:11 AM, Antonio Salazar Cardozo <savedf...@gmail.com> wrote:
Whoa, where did the randomname parameter come from?

A random sprinkling of API dust from the @dpp fairy ;-)

Joseph Shraibman

unread,
Apr 27, 2012, 5:52:50 PM4/27/12
to lif...@googlegroups.com
Did some more testing and randomname="true" does fix the problem.

If anyone is interested in replicating the problem clone https://github.com/josephks/lift-playpen and modify jvmmem.xhtml to take out  randomname="true"
Reply all
Reply to author
Forward
0 new messages