Web2 Ghost Sessions

Related discussion: 2021 R3.1 - Lost Connection Behavior Different? - #15 by Mike_D

I’ve added more debugging to my Web2 app and am seeing what appear to be “Ghost” sessions - these are sessions that exist for a long time, but do not have an active web page.

Here’s an example from this morning:


The first and last sessions are legit, but the middle 8 sessions are “ghost” ones. Oddly, they all were created at exactly the same time.

I’m not sure if this is a bug in 2021 R3.1 or something that I need to scan for and clean up myself?

Edit: oddly, the calculated session age is wrong, too.

I have this code:

     createdMicroseconds = system.Microseconds

And yet if you back calculate the session age, 1969581 seconds is about 547 hours, which is how long since I last rebooted the server - this means createdMicroseconds = 0, and thus the session.Opening event never actually fired for these ghost sessions. Very odd.

Could they be sockets that are prepared but not connected yet (serversocket) ?
It seems very strange to have sessions for no use, wasting memory… ?

Interesting, if I look at my log, I do see a number of NilObjectExceptions that are being handled. Each one looks like this:

[2022-01-27 17:25:45] unknown : 82BDB8 Session.opening smith001 page='/' class='' opened from XX.XX.40.249 size=1280x567 browser: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:96.0) Gecko/20100101 Firefox/96.0
[2022-01-27 17:25:45] unknown : 82BDB8 smith001 Login cookie match
[2022-01-27 17:25:45] smith001 : 82BDB8 (cookie) login
[2022-01-27 17:26:00] smith001 : 82BDB8 disconnected
[2022-01-27 17:26:33] smith001 : 82BDB8  closing
[2022-01-27 17:26:33] [nil] App.UnhandledException (none) 0 : RuntimeRaiseException

It’s mostly happening with this single user ‘smith002’ who is on Firefox 96, and the # of ghost sessions is close to the # of times I see this in the log.

Maybe the ghost sessions are leftovers when Session.Closing is throwing this exception?

Looks like something is buggy here… Exception handling is slow so using that in a web framework would be a bad choice.

I’m able to reproduce this in the debugger now - the debugger breaks into SessionShutdownThread (but there is no code visible, presumably since it’s breaking into the framework). I’ll see if I can come up with a minimal reproducible case and file it.

Submitted as <https://xojo.com/issue/67519> with a demo project. It seems browser-specific, as I’m seeing it with Firefox 96 but not Safari.

1 Like

With Safari, I see a different issue, where Session.userTimedOut never fires.

Submitted as <https://xojo.com/issue/67520>

We have seen those in Web 1 and for us it’s a monitoring app used by the server admins, which tries to connect, but doesn’t load the website.

We ignore those and after 2 minutes such a session disappears, although it makes the server showing lots of those sessions at all times.