I think there are two separate (or maybe related ??) problems described in this discussion:
One is where UserSessionService.getUserSession() always returns null. And the fix (??) is probably related to this statement
"Actually, when we developed any plugin for vCenter, we need to perform authentication with the help of .html pages.
In my case, I was trying to retrieve current user session before authentication of .html page. Hence we were getting userSessionService.getUserSession() as null. "
from the link in post 11 : https://code.vmware.com/forums/4974#573581
The second problem is described in post 6 and we are also hitting it with Site recovery plugin. The problem is that UserSessionService.getUserSession() works as expected and returns the correct current user session but eventually after leaving the vSphere client open for more time at some point it starts returning null with the corresponding message in the logs:
[2017-10-12T14:47:03.578Z] [INFO ] http-bio-9443-exec-18 c.vmware.vsphere.client.usersession.impl.UserSessionServiceImpl getUserSession called on an inactive session.
And this problem resolves after logging out and loggin in again in the vSphere client.
Is the second problem a known issue that is fixed in the vSphere 6.5u1 ? We haven't had a chance to test with it yet.