cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Announcements
Announcements
Choose one of the topics below to view our ISE Resources to help you on your journey with ISE

This community is for technical, feature, configuration and deployment questions.
For production deployment issues, please contact the TAC! We will not comment or assist with your TAC case in these forums.
Please see How to Ask the Community for Help for other best practices.

933
Views
20
Helpful
7
Replies
Highlighted
Beginner

REST API to ISE server to close down existing connection?

Is it possible to send a REST API request to the ISE server to logout the current session?

Let's say, I am using this in python After the get, I want to close down the session gracefully. session.close() doesn't seem to close the session down.

Thanks.

client = requests.session()
response=client.get(url, headers=headers, verify=False)

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

AFAIK you should be able to close the connection via setting it in your headers OR via closing it on client side once the request is done. Try printing the returned headers from the server after you send your request to ensure you have properly set the connection to close via your request header:
response = client.get(client.url)
print response.headers

Or test it via:
response = client.get(client.url)
response.close()

View solution in original post

7 REPLIES 7
Highlighted
VIP Engager

Have you tried adding 'connection': 'close' to your HEADERS? I think that may do the trick. If not try this:
conn = requests.session()
conn.config['keep_alive'] = False
HTH!
Highlighted

Thanks Mike.

 

I tested the below, but it's weird that the 2nd request.get's response.status_code is still 200. I intentionally messed up the credential too, with 'xyz'. Since the connection is closed by then, I was expecting some type of error, not 200.

I thought, after the 1st client.get, the connection is closed. Then, the 2nd client.get should return something other than 200.

Thought?

client.headers['Connection'] = 'close'
client.headers['authorization'] = 'xyz'
response = client.get(client.url)
response = client.get(client.url)

Highlighted

AFAIK since you are initiating multiple GET requests they will be successful since you are initiating a new request (obviously given that the code works as expected). Try printing the response in between the two requests to see the differences in the sessions.
Highlighted

The response.content are exactly the same.
Highlighted

AFAIK you should be able to close the connection via setting it in your headers OR via closing it on client side once the request is done. Try printing the returned headers from the server after you send your request to ensure you have properly set the connection to close via your request header:
response = client.get(client.url)
print response.headers

Or test it via:
response = client.get(client.url)
response.close()

View solution in original post

Highlighted

Thanks Mike!

 

I did the following.  What I found out is that, the first 2 prints of the headers produce the same information.  The 2nd  client.get(url) gets the same result/data as the 1st client.get(url).  So, that means, the resp.close() doesn't seem to close down the connection.  If it did, the 2nd client.get(url) wouldn't return the valid device data from ISE server.

 

Kind of strange.

 

resp = client.get(url)
print(resp.headers)
resp.close()
print(resp.headers)
resp = client.get(url)
print (resp.text)
Highlighted

If I don't do a session close (either via resp.close(), or headers['connection'] = 'close'), is there a session timeout timer set on the ISE server that will eventually tear down the session (from the client)?

 

Or the question really is, is there a session timeout timer set on the ISE server to tear the session down, if the session stays idle too long?  

Content for Community-Ad