Check that the connection hasn't been closed already before calling
the onConnection callback.
Merge branch 'session-hooks' into hash-login-tokens