cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2364
Views
20
Helpful
7
Replies

REST API to ISE server to close down existing connection?

pn2020
Level 1
Level 1

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

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

Mike.Cifelli
VIP Alumni
VIP Alumni
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!

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)

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.

The response.content are exactly the same.

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()

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)

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?  

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: