VMware {code} Community
rampang
Contributor
Contributor

UserSession and login() method

If the session is inactive for a period of 30 mins, found that subsequent APIs return null Objects. What is the best method to re login again? Any sample code? Can anyone provide any clues on how to keep the session running for longer periods of inactive time?

Thanks

0 Kudos
3 Replies
admin
Immortal
Immortal

Hi,

There are basically two types of timeouts, session timeout and SOAP timeout. Session timeout is when you have gained authentication for a session, and no request is send to the server for 30mins, the session timeouts. This behavior is by design. So, to avoid the same you need to keep the session active and invoke API operations within each 30 mins of time frame.

Now, to increase the SOAP timeout, which basically comprises of the client timeout settings ( timeout if server has responded but the client is taking time to read the response) , you can refer to the SoapHttpClientProtocol which has a timeout property. For .Net, how to perform the timeout changes are captured in kb article:

http://kb.vmware.com/kb/1002576

If you are using Axis, you can set the timeout on a Java stub.

VimPortType service = serviceLocator.getVimPort(new URL(urlStr));

//Example, set socket timeout to 30 minutes or 1800 seconds.

((org.apache.axis.client.Stub)service).setTimeout(1800000);

// or no timeout

//((org.apache.axis.client.Stub)service).setTimeout(0);

Hope this would be helpful.

rampang
Contributor
Contributor

In our case, session timeout is causing an issue due to inactivity for long period of time. If the session timeout happens due to inactivity, is it possible detect it when we invoke the API after 30 mins inactivity? How to get the new session again to have the APIs to work after inactivity?

Thanks

0 Kudos
admin
Immortal
Immortal

Hi,

To provide a 'timeout' for SSL Connections and HTTP connections to an ESX Server, you need to do following:

Set the SSL handshake timeout in /etc/vmware/hostd/config.xml as follows:

file /etc/vmware/hostd/config.xml:

-


---

Note:above indicates continuity of file. It is just used to indicate lines of code not included in this context.

-


After making the above changes, restart mgmt-vmware service. You can set the timeout value as per your choice, here it is set as 15000 ms i.e 20 secs.

- Angela -

0 Kudos