Hi,
I have some database connection at session level. I detect some Pooled connection request timed out errors when connecting to database (Oracle, if that matters).
I close/dispose connection on ApplicationExit event, but in logs (my logs) there are no entries proving that this event is fired.
Please tell me where is the best moment/place to dispose my database connection?
Hi Adrian,
this was logged as #2443 and is fixed in our latest development build (2.1.16).
Best regards
Frank
Tried this as a temp workaround:
Application.Session.DetectSessionDisposed = new DetectSessionDisposed(Application.Session); internal class DetectSessionDisposed { dynamic session; public DetectSessionDisposed(dynamic session) { // just in case you need to access objects in the session this.session = session; } ~DetectSessionDisposed() { // this code is executed when the session is expired and the GC collects the objects. } }
The ApplicationExit event is (should be) fired when the session is disposed. The session is disposed approximately after sessionTimeout * 2 seconds of “inactivity” or if you call Application.Exit(). Inactivity usually means that the client has lost connection (which could mean it was turned off) or the browser or tab are closed. If the app is loaded on a tab it may never expire because there is a keepalive heartbeat – it will show the built-in session-expiring form unless you handle the SessionExpired event.
But… there appears to be a regression causing it to be fired only if you call Application.Exit(). I’m not sure when it was introduced. Will log the bug, should be in the next build.
The session is disposed correctly though allowing the GC to dispose any related object so the connections should still be disposed by the GC.
Please login first to submit.