Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

end_session can‘t terminate the session,cause session persistence. #28

Open
keymou opened this issue Jun 15, 2023 · 3 comments
Open

Comments

@keymou
Copy link

keymou commented Jun 15, 2023

Environment: Windows7
stcrestclient: 1.9.0
python:3.8

from stcrestclient import stchttp

class Stc(object):

	def __init__(self, server: str = '127.0.0.1', port: int = '8888', **kwargs):
        self.server = server
        self.port = port
        self.stc = stchttp.StcHttp(f'{self.server}:{self.port}')
        self.sid = self.stc.new_session('auto', 'auto', kill_existing=True, analytics=True)

    def close_session(self):
        try:
            self.stc.end_session(end_tcsession='kill', sid=None)
        except Exception:
            crash_logger().exception('An exception occurs when close stchttp session.')    

end_session cannot disconnect the session. The TestCenterSession.exe created by new_session can still be seen through the task manager and is in the running state. This will cause a problem. Call new_session repeatedly to create a new session, and eventually the number of connections will exceed the maximum number of connections in the server thread pool, resulting in the creation of session failed
Hopefully the end_session can be fixed.

@jservidio
Copy link
Collaborator

It looks like you are using the client with SpirentTestCenter's stcweb (since it port 8888). The end_tcsession='kill' option for stc.end_session() is not supported by stcweb yet (it is only supported on the SpirentTestCenter LabServer's stc-rest-api service). There is an open PR to provide it on stcweb (https://github.com/SpirentOrion/stc-web/pull/94) but it was never submitted. Not sure whether there was a problem with those changes or not.

At this point we are investigating replacing the LabServer stc-rest-api service with stcweb and as part of that, the 'kill' option will have to be supported. So we will soon be looking into that PR to see if there was an issue with it, and if so, what needs to be done to get it working to the point that it can be submitted.

@keymou
Copy link
Author

keymou commented Jun 16, 2023

It looks like you are using the client with SpirentTestCenter's stcweb (since it port 8888). The end_tcsession='kill' option for stc.end_session() is not supported by stcweb yet (it is only supported on the SpirentTestCenter LabServer's stc-rest-api service). There is an open PR to provide it on stcweb (https://github.com/SpirentOrion/stc-web/pull/94) but it was never submitted. Not sure whether there was a problem with those changes or not.

At this point we are investigating replacing the LabServer stc-rest-api service with stcweb and as part of that, the 'kill' option will have to be supported. So we will soon be looking into that PR to see if there was an issue with it, and if so, what needs to be done to get it working to the point that it can be submitted.

Thank you for your response. appreciate your efforts and hope to see this submitted soon.

@jservidio
Copy link
Collaborator

@keymou after looking into this a bit more, it appears that it should be working with stcweb. In my testing the only time it did not terminate the TestCenterSession.exe was when I tried to kill the session without actually being joined to it, so it didn't know which session to kill.

In your code example in close_session, is there some reason you don't want to just set the sid parameter to be self.sid, instead of None?

   self.stc.end_session(end_tcsession='kill', sid=self.sid)

That way, even if you have somehow become disassociated with the session at the time it is called, it would still work.

If you are sure the session is still joined at the time close_session is called, maybe you can provide more details about that particular scenario?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants