Hi laurentsd, I faced a problem about using com.vmware.vise.usersession.UserSessionService for getting user session from vSphere Client, when I take the getUserSession() method from UserSessionService to develop our plugin in vSphere Client, the vSphere Client log reports the information like this:
[2017-04-17T18:03:19.392+08:00] [INFO ] http-bio-9443-exec-8 com.vmware.vsphere.client.security.util.Util getUserSession called on an inactive session.
[2017-04-17T18:03:19.393+08:00] [ERROR] http-bio-9443-exec-8 com.emc.vsi.services.usersession.UserSessionInfoServiceImpl UserSession is null
Obviously from com.vmware.vise.usersession.UserSessionService you get the user session is null. I wonder why it would lead to such a result and how can I get the user session correctly from vSphere Client using the method?
We use the html-client-sdk(version: 6.5.0, build: 5097204), and our code implement like this:
Also we inject UserSessionService by OSGI bundle like this:
Thank you for your reply, but I can not understand what you mean. Do you mean we need call our method getAllUserSessionsWithMultiIps() within an active user session?
Reference our code of calling the method in services controller by matching the endpoint:
But I think the call method as described above is no problem, because in flex client(Now we have migrated previous Java service using in html client), we can use the method getUserSession() which is in the UserSessionService from VMware package com.vmware.vise.usersession to get the user session correctly.
As you see before, we store the cache for vise.usersession.UserSessionService by the OSGI bean in our code, and try to call the method getUserSession() in UserSessionService.
So how can we get the user session using the method getUserSession() correctly now?
Thanks in advance.
Are you saying that the exact same code works with the Flex client?
I don't quite get what you're trying to accomplish with caching UserSessionDetails.
Sorry, I can't comment on what is wrong without seeing a working example (the best, as usual, is to modify one of the SDK samples just enough to reproduce your problem so that I can run it locally)
UserSessionService is injected correctly in samples/vsphere-wssdk-service/src/main/java/com/vmware/samples/vspherewssdk/DataProviderImpl.java for instance.
Hi laurentsd, I have changed another vCenter 6.5 for developing Java code, and this issue is disappeared. So I suspect that there may be environmental problems, if I have reproduced this issue, I will ask you for help. Thanks.
Hi laurentsd, i am also facing the same problem in our html plugin(server extension)
1. I access the html pages of my html plugin and leave it idle for some time (may be more than 20 min).
2. Now when i try to access any of the plugin pages userSessionService.getUserSession() is returning an expired session.
3. Either i can logout & login back or when i try to access any of the VMware pages and come back to try the plugin then userSessionService.getUserSession() returns a proper session.
So i am having a feeling that VMware pages don't access the session through userSessionService.getUserSession() call, thus their session never expires or if it expires also it gets renewed for some reason.
Is this issue get fixed?
I have same issue (userSessionService.getUserSession() returns null) while retrieving user session from com.vmware.vise.usersession.UserSessionService in java.
We are also hitting this issue occasionally in Site recovery plugin using the HTML SDK when deployed in VC 6.0u3. The way we are using the UserSessionsService is the same as in vsphere-wssdk-service project from the SDK samples.
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.
We're seeing this issue as well on 6.0U1. The user logs in to a linked mode vCenter. Creates a datacenter, adds two hosts, one to each vCenter.
Then the user clicks on my plugin which makes a call,
UserSession userSession = userSessionService.getUserSession();
which returns null.
Just wondering if we could get a little more info on which update might have the fix. (Asking for all my customers)
I am also seeing this issue with getUserSession() returning null after a period of time. This is on vCenter Server 6.5U1 and vCenter Server 6.5U1b.
It doesn't seem to be necessary to log in and out of the vSphere Client UI to get a vaild session; just navigating to a VMWare-implemented page and back to our plugin seems to be sufficient.
Is there a way to perform the same keep-alive/reconnect action from our own UI code (HTML-side or Java) to ensure that the session is valid before we try to use it?
As Already mentioned by stoevm in previous comment. I have already find the resolution for this problem and I have mentioned it in another thread. (Link of that thread)
Below are the details of problem with solution.
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.
Before executing UserSession userSession = userSessionService.getUserSession(); this line, perform authentication of your request by hitting any .html page from your vCenter plugin with the help of plugin.xml.
Hope you get the solution for your problem.
The mentioned workaround should do for now.
Yet, I agree with Chris a keep alive mechanism is the best approach. A regular ping from the HTML Client to the plugin view is already being developed and should be delivered in one of the next releases.