HewlettPackard / oneview-python

Python library for HPE OneView
https://github.com/HewlettPackard/oneview-python/wiki
Apache License 2.0
28 stars 27 forks source link

Too many sessions error. Python library for HPE OneView doesn't close connections #101

Closed jsalgado78 closed 3 years ago

jsalgado78 commented 4 years ago

Hello,

I'm using Python library for HPE OneView v5.4.0 to monitor HPE OneView , last firmware version, with Nagios but I'm getting this error two days later I had configured monitoring:

HPEOneViewException: (u'Login denied. The client xxx.xxx.xxx.xxx has too many active sessions.', {u'errorSource': None, u'recommendedActions': [u'Do one of the following: log out of existing sessions. Log in from a different IP address. Contact the administrator to increase the maximum number of sessions per client IP address. Wait 24 hours for idle sessions created by scripts to time out and then retry logging in.'], u'data': {u'clientip': u'xxx.xxx.xxx.xxx'}, u'errorCode': u'AUTHN_SESSION_CLIENT_LIMIT_CROSSED', u'messageParameters': [u'xxx.xxx.xxx.xxx'], u'details': u'The client xxx.xxx.xxx.xxx has the maximum number of active sessions allowed.', u'message': u'Login denied. The client xxx.xxx.xxx.xxx has too many active sessions.', u'nestedErrors': []})

Python library for HPE OneView doesn't appear to close connections on HPE OneView before OneViewClient is destroyed.

Thanks.

nabhajit-ray commented 4 years ago

Thanks for bringing this up. We will look into this and get back to you

VenkateshRavula commented 3 years ago

@jsalgado78 , We are not able to reproduce this issue in our environment. Also we didn't face this issue anytime before. Do you any idea about how many active sessions are present in your environment at the time of this issue.? If possible we will try to create those number of active sessions in our environment.

It will be helpful for us if you can sync up with us in live session.

jsalgado78 commented 3 years ago

I had about eight nagios checks running every five minutes for two or three days to get this error.

I've resolved this error opening a session, saving SessionID to a file and reusing this SessionID at every Nagios check.

I've attached an example

Thanks alerts.py.gz

VenkateshRavula commented 3 years ago

@jsalgado78 , Good to hear that you are not blocked currently. We are looking into the permanent resolution for this issue and soon will let you know.

VenkateshRavula commented 3 years ago

@jsalgado78 , In our python SDK, we basically support 2 login mechanisms - one by providing credentials (username and password) and another by sessionID. The latter one is supported as we have few Customers who follows the login by sessionID. This is to reuse the same session ID for further executions and avoid generation of sessionID for each and every SDK execution.

Hence with regards to supporting the sessionID re-use, we won’t handle automatic session logouts in our SDK.

But at the same time our SDK provides logout method in connection class where users can explicitly call the logout method at the end of their execution. This is to terminate the sessionID. We can leverage this feature for fixing the “Too many sessions” error.

We are sharing the modified script by adding the connection.logout() at the end. Please find the attached modified script.

Hope our explanation helps. Please share your comments if any.

alerts.zip

VenkateshRavula commented 3 years ago

Hi @jsalgado78 , It has been more than 10 days that we didn't hear back from you. So we assume that the solution we provided helped you out and hence closing this issue. Please feel free to reopen this issue if the issue still persists.