Project

General

Profile

Destroying sessions when no more clients are connected

Added by Rob Van Dyck over 11 years ago

Hi,

I have a problem to get all my sessions destroyed for any wt app. The problem is reproducible in Chrome/Chromium, not in Iceweasel. I tried this using Wt 3.2.1 and 3.2.3.

If I open up a browser (creates session A), refresh it by pressing control-R (creates session B) and then close it right away before the session timeout of A (deletes session B), session A doesn't get destroyed until I open a third browser (create session C, kills session A).

Is there a way to make sure that session A is killed? It looks like expireSessions() in web/WebController.cpp is only called while there is at least one browser connected, that is why A isn't deleted for me untill session C comes into play (the diff value for A is negative then).

My logs show this:

[2012-Dec-26 10:36:03.340196] 11114 - [info] "config: reading Wt config file: /home/robvdy/software/vfe/trunk/stage/www/docroot/wt_config.xml (location = '/home/robvdy/software/vfe/trunk/build/gnu-make-eclipse/gcc-elf/release/tryouts/interfaces/wt/small_example/small_example.wt')"
[2012-Dec-26 10:36:03.341674] 11114 - [info] "WServer/wthttp: initializing built-in wthttpd"
[2012-Dec-26 10:36:03.342277] 11114 - [info] "wthttp: started server: http://0.0.0.0:8080"
[2012-Dec-26 10:36:09.247169] 11114 - [info] "Wt: session created (#sessions = 1)"       [CREATES SESSION A]
[2012-Dec-26 10:36:09.247413] 11114 [/ kfxxClRSCTDHW9ET] [info] "WEnvironment: UserAgent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.97 Safari/537.11"
[2012-Dec-26 10:36:09.248481] 11114 - [info] "WebRequest: took 1.436ms"
127.0.0.1 - - [2012-Dec-26 10:36:09.248425] "GET / HTTP/1.1" 200 1894
[2012-Dec-26 10:36:09.267491] 11114 - [info] "WebRequest: took 3.72ms"
127.0.0.1 - - [2012-Dec-26 10:36:09.267432] "GET /?wtd=kfxxClRSCTDHW9ET&request=style HTTP/1.1" 200 91
[2012-Dec-26 10:36:09.276856] 11114 - [info] "WebRequest: took 10.49ms"
127.0.0.1 - - [2012-Dec-26 10:36:09.276798] "GET /?wtd=kfxxClRSCTDHW9ET&sid=63850229&htmlHistory=true&deployPath=%2F&request=script&rand=469323744 HTTP/1.1" 200 33693
[2012-Dec-26 10:36:09.369413] 11114 - [info] "WebRequest: took 0.358ms"
127.0.0.1 - - [2012-Dec-26 10:36:09.369374] "POST /?wtd=kfxxClRSCTDHW9ET HTTP/1.1" 200 48
[2012-Dec-26 10:36:12.156180] 11114 - [info] "Wt: session created (#sessions = 2)"       [CREATES SESSION B]
[2012-Dec-26 10:36:12.156349] 11114 [/ EpsG3VtKe5q42wUS] [info] "WEnvironment: UserAgent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.97 Safari/537.11"
[2012-Dec-26 10:36:12.157320] 11114 - [info] "WebRequest: took 1.219ms"
127.0.0.1 - - [2012-Dec-26 10:36:12.157252] "GET / HTTP/1.1" 200 1896
[2012-Dec-26 10:36:12.178103] 11114 - [info] "WebRequest: took 10.657ms"
127.0.0.1 - - [2012-Dec-26 10:36:12.178051] "GET /?wtd=EpsG3VtKe5q42wUS&request=style HTTP/1.1" 200 91
127.0.0.1 - - [2012-Dec-26 10:36:12.181802] "GET /resources/themes/default/wt.css HTTP/1.1" 304 0
127.0.0.1 - - [2012-Dec-26 10:36:12.182051] "GET /resources/webkit-transitions.css HTTP/1.1" 304 0
[2012-Dec-26 10:36:12.187722] 11114 - [info] "WebRequest: took 10.683ms"
127.0.0.1 - - [2012-Dec-26 10:36:12.187669] "GET /?wtd=EpsG3VtKe5q42wUS&sid=3480684554&htmlHistory=true&deployPath=%2F&request=script&rand=200589882 HTTP/1.1" 200 33695
[2012-Dec-26 10:36:12.275852] 11114 - [info] "WebRequest: took 0.413ms"
127.0.0.1 - - [2012-Dec-26 10:36:12.275796] "POST /?wtd=EpsG3VtKe5q42wUS HTTP/1.1" 200 50
[2012-Dec-26 10:36:13.612047] 11114 - [info] "WebRequest: took 1333.93ms"
[2012-Dec-26 10:36:13.612624] 11114 [/ EpsG3VtKe5q42wUS] [info] "Wt: session destroyed (#sessions = 1)"       [DELETES SESSION B]
[2012-Dec-26 10:36:13.612678] 11114 - [info] "WebRequest: took 1.019ms"


...   [wait till end of time or open a third browser]


[2012-Dec-26 10:38:53.272861] 11114 - [info] "Wt: session created (#sessions = 2)"       [CREATE SESSION C]
[2012-Dec-26 10:38:53.272987] 11114 [/ qjVYbvRoogwVIjSx] [info] "WEnvironment: UserAgent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.97 Safari/537.11"
[2012-Dec-26 10:38:53.273323] 11114 [/ kfxxClRSCTDHW9ET] [info] "WebController: timeout: expiring"
[2012-Dec-26 10:38:53.273499] 11114 [/ kfxxClRSCTDHW9ET] [info] "Wt: session destroyed (#sessions = 1)"       [DELETES SESSION A]
[2012-Dec-26 10:38:53.273614] 11114 - [info] "WebRequest: took 163902ms"
[2012-Dec-26 10:38:53.273666] 11114 - [info] "WebRequest: took 0.868ms"
127.0.0.1 - - [2012-Dec-26 10:38:53.273598] "GET / HTTP/1.1" 200 1893
[2012-Dec-26 10:38:53.296194] 11114 - [info] "WebRequest: took 3.604ms"
127.0.0.1 - - [2012-Dec-26 10:38:53.296148] "GET /?wtd=qjVYbvRoogwVIjSx&request=style HTTP/1.1" 200 91
[2012-Dec-26 10:38:53.305264] 11114 - [info] "WebRequest: took 9.865ms"
127.0.0.1 - - [2012-Dec-26 10:38:53.305211] "GET /?wtd=qjVYbvRoogwVIjSx&sid=369618191&htmlHistory=true&deployPath=%2F&request=script&rand=1374534944 HTTP/1.1" 200 33695
[2012-Dec-26 10:38:53.401770] 11114 - [info] "WebRequest: took 0.36ms"
127.0.0.1 - - [2012-Dec-26 10:38:53.401732] "POST /?wtd=qjVYbvRoogwVIjSx HTTP/1.1" 200 49
[2012-Dec-26 10:38:58.401894] 11114 - [info] "WebRequest: took 4997.69ms"
[2012-Dec-26 10:38:58.402118] 11114 - [info] "WebRequest: took 0.448ms"
127.0.0.1 - - [2012-Dec-26 10:38:58.402080] "POST /?wtd=qjVYbvRoogwVIjSx HTTP/1.1" 200 49
[2012-Dec-26 10:39:03.402540] 11114 - [info] "WebRequest: took 4998.5ms"
[2012-Dec-26 10:39:03.402843] 11114 - [info] "WebRequest: took 0.57ms"
127.0.0.1 - - [2012-Dec-26 10:39:03.402794] "POST /?wtd=qjVYbvRoogwVIjSx HTTP/1.1" 200 49
[2012-Dec-26 10:39:04.671644] 11114 - [info] "WebRequest: took 1267.3ms"
[2012-Dec-26 10:39:04.671868] 11114 [/ qjVYbvRoogwVIjSx] [info] "Wt: session destroyed (#sessions = 0)"       [DELETES SESSION C]
[2012-Dec-26 10:39:04.671969] 11114 - [info] "WebRequest: took 0.608ms"

I am using wthttpd and have the following options in my config file:

true

10 ==> just for testing purposes

Thanx for any input!

Rob.


Replies (3)

RE: Destroying sessions when no more clients are connected - Added by Koen Deforche over 11 years ago

Hey Rob,

What you're seeing is that indeed sessions only expire when a request is received. There is no separate timer to time-out sessions and the reason is more historic: at the time we did not have a portable event source within Wt.

Nowadays, we have a WIOService, so we could actually implement session expiration more accurately. The trade-off so far has worked since only on heavy load it becomes important to expire sessions to conserve memory.

Regards,

koen

RE: Destroying sessions when no more clients are connected - Added by Wim Dumon over 11 years ago

In the meantime you can call WServer::expireSessions() every now and then, e.g. from a timer in WIOService...

Wim.

RE: Destroying sessions when no more clients are connected - Added by Rob Van Dyck over 11 years ago

Hey Koen and Wim,

Thanx for the info!

Regards,

Rob.

    (1-3/3)