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

SWATError: Unknown session.: <session-reference> #146

Closed
githje opened this issue Dec 21, 2022 · 1 comment
Closed

SWATError: Unknown session.: <session-reference> #146

githje opened this issue Dec 21, 2022 · 1 comment

Comments

@githje
Copy link

githje commented Dec 21, 2022

Hi,

we're trying to connect to a 2022.09 LTS cluster through the nginx ingress using the latest SWAT package. The constructor call fails with this message:

SWATError: Unknown session.: 3dfeb19a-09e2-674e-ad1e-ab78338ff9af

This is similar to an issue we've found here, but note that our error actually lists a CAS session reference which looks ok. The log output seems to indicate that the 1st REST call returns a valid session reference which is not recognized by the 2nd call?

There are no related error messages in the CAS log. How can we further debug this? (on the SAS/Kubernetes side maybe?). The Viya environment is hosted on AWS.

Thanks for looking into this!

Here's our test code:

os.environ['CAS_CLIENT_SSL_CA_LIST']='C:\\Users\\myuser\\Documents\\trustedcerts.pem'

swat.options.cas.debug.requests = True
swat.options.cas.debug.request_bodies = True
swat.options.cas.debug.responses = True
swat.options.cas.print_messages = True

conn = swat.CAS('https://sasviya-nlb.somemachine.com:443/cas-shared-default-http/', 
  username='myuser', password=getpass.getpass("Enter password"))

This is the log output (abbreviated):

PUT https://sasviya-nlb.somemachine.com:443/cas-shared-default-http/cas/sessions
User-Agent: python-requests/2.28.1
Accept-Encoding: gzip, deflate
Accept: application/json
Connection: keep-alive
Content-Type: application/json
Content-Length: 0
Authorization: b'Basic XYZ123=='

RESPONSE text: 
{ "session": "3dfeb19a-09e2-674e-ad1e-ab78338ff9af" }

POST https://sasviya-nlb.somemachine.com:443/cas-shared-default-http/cas/sessions/3dfeb19a-09e2-674e-ad1e-ab78338ff9af/actions/builtins.serverstatus
User-Agent: python-requests/2.28.1
Accept-Encoding: gzip, deflate
Accept: application/json
Connection: keep-alive
Content-Type: application/json
Content-Length: 43
Authorization: b'Basic XYZ123=='
tkhttp-id: L/o00jB/M60ST7zV...SG9nbMg

{"_apptag": "UI", "_messagelevel": "error"}

RESPONSE text: 
{
  "error": "Unknown session.",
  "code": "SessionUnknown",
  "details": "3dfeb19a-09e2-674e-ad1e-ab78338ff9af",
  "disposition": null
}

---------------------------------------------------------------------------
SWATError                                 Traceback (most recent call last)
Cell In[5], line 1
----> 1 conn = swat.CAS('https://sasviya-nlb.somemachine.com:443/cas-shared-default-http/', 
      2                 username='myuser', password=getpass.getpass("Enter password"))

File C:\devtools\Python3\lib\site-packages\swat\cas\connection.py:478, in CAS.__init__(self, hostname, port, username, password, session, locale, nworkers, name, authinfo, protocol, path, ssl_ca_list, authcode, **kwargs)
    473 self._results_hooks = {}
    475 # Get server attributes
    476 (self.server_type,
    477  self.server_version,
--> 478  self.server_features) = self._get_server_features()
    480 # Preload __dir__ information.  It will be extended later with action names
    481 self._dir = set([x for x in super_dir(CAS, self)])

File C:\devtools\Python3\lib\site-packages\swat\cas\connection.py:587, in CAS._get_server_features(self)
    577 '''
    578 Determine which features are available in the server
    579 
   (...)
    583 
    584 '''
    585 out = set()
--> 587 info = self._raw_retrieve('builtins.serverstatus', _messagelevel='error',
    588                           _apptag='UI')
    589 if info.severity > 1:
    590     raise SWATError(info.status)

File C:\devtools\Python3\lib\site-packages\swat\cas\connection.py:1815, in CAS._raw_retrieve(self, _name_, **kwargs)
   1812 ''' Call a CAS action without parameter checking and return results '''
   1813 try:
   1814     # Call the action and compile the results
-> 1815     self._invoke_without_signature(a2n(_name_), **kwargs)
   1816     return self._get_results(getnext(self))
   1817 except SWATCASActionRetry:

File C:\devtools\Python3\lib\site-packages\swat\cas\connection.py:1236, in CAS._invoke_without_signature(self, _name_, **kwargs)
   1219 '''
   1220 Call an action on the server
   1221 
   (...)
   1233 
   1234 '''
   1235 if isinstance(self._sw_connection, rest.REST_CASConnection):
-> 1236     errorcheck(self._sw_connection.invoke(a2n(_name_), kwargs),
   1237                self._sw_connection)
   1238 else:
   1239     errorcheck(self._sw_connection.invoke(a2n(_name_),
   1240                                           py2cas(self._soptions,
   1241                                                  self._sw_error, **kwargs)),
   1242                self._sw_connection)

File C:\devtools\Python3\lib\site-packages\swat\cas\rest\connection.py:725, in REST_CASConnection.invoke(self, action_name, kwargs)
    723     if self._results.get('details'):
    724         msg = '{}: {}'.format(msg, self._results['details'])
--> 725     raise SWATError(msg)
    726 else:
    727     raise SWATError('Unknown error')

SWATError: Unknown session.: 3dfeb19a-09e2-674e-ad1e-ab78338ff9af
@githje
Copy link
Author

githje commented Dec 22, 2022

I'm closing this one - it turned out that the problem was caused by a case mismatch in the user ID - we had to make sure to enter the user ID "all uppercase" ("MYUSERID" vs. "myuserid"). I also just found this setting: env.CASUSERIGNORECASE='ON' which should make things even easier.

@githje githje closed this as completed Dec 22, 2022
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

1 participant