sassoftware / saspy

A Python interface module to the SAS System. It works with Linux, Windows, and Mainframe SAS as well as with SAS in Viya.
https://sassoftware.github.io/saspy
Other
373 stars 150 forks source link

We failed in getConnection An exception was thrown during the encryption key exchange. #470

Closed Samuelnikhade closed 2 years ago

Samuelnikhade commented 2 years ago

I'm trying to connect SAS ODA via Windows Machine

With the help of below link, I have made changes in "sascfg_personal.py" and "_authinfo" https://support.sas.com/ondemand/saspy.html

Below code which I'm trying to execute in Pycharm import saspy sas = saspy.SASsession()

below are the installation in my system Conda Python version : 3:10 Saspy version : saspy-4.2.0 Java version : "1.8.0_333"

Below is the error that Im getting

C:\Users\sam.conda\envs\sastopython\python.exe C:/Users/sam/PycharmProjects/try1sastopy/testsas2py.py Using SAS Config named: oda Traceback (most recent call last): File "C:\Users\sam\PycharmProjects\try1sastopy\testsas2py.py", line 8, in sas = saspy.SASsession(cfgfile='C:/Users/sam/.conda/envs/try1sastopy/Lib/site-packages/saspy/sascfg_personal.py') File "C:\Users\sam.conda\envs\sastopython\lib\site-packages\saspy\sasbase.py", line 599, in init raise SASIOConnectionError(res) saspy.sasexceptions.SASIOConnectionError: Failure establishing SASsession. No SAS process attached. SAS process has terminated unexpectedly. We failed in getConnection An exception was thrown during the encryption key exchange.

SAS process has terminated unexpectedly. RC from wait was: 4294967290 SAS Connection failed. No connection established. Double check your settings in sascfg_personal.py file.

Attempted to run program C:\Program Files (x86)\Common Files\Oracle\Java\javapath\java.exe with the following parameters:['C:\Program Files (x86)\Common Files\Oracle\Java\javapath\java.exe', '-classpath', 'C:\Users\sam\.conda\envs\sastopython\lib\site-packages\saspy\java\saspyiom.jar;C:\Users\sam\.conda\envs\sastopython\lib\site-packages\saspy\java\iomclient\log4j-1.2-api-2.12.4.jar;C:\Users\sam\.conda\envs\sastopython\lib\site-packages\saspy\java\iomclient\log4j-api-2.12.4.jar;C:\Users\sam\.conda\envs\sastopython\lib\site-packages\saspy\java\iomclient\log4j-core-2.12.4.jar;C:\Users\sam\.conda\envs\sastopython\lib\site-packages\saspy\java\iomclient\sas.security.sspi.jar;C:\Users\sam\.conda\envs\sastopython\lib\site-packages\saspy\java\iomclient\sas.core.jar;C:\Users\sam\.conda\envs\sastopython\lib\site-packages\saspy\java\iomclient\sas.svc.connection.jar;C:\Users\sam\.conda\envs\sastopython\lib\site-packages\saspy\java\iomclient\sas.rutil.jar;C:\Users\sam\.conda\envs\sastopython\lib\site-packages\saspy\java\iomclient\sas.rutil.nls.jar;C:\Users\sam\.conda\envs\sastopython\lib\site-packages\saspy\java\iomclient\sastpj.rutil.jar;C:\Users\sam\.conda\envs\sastopython\lib\site-packages\saspy\java\thirdparty\glassfish-corba-internal-api.jar;C:\Users\sam\.conda\envs\sastopython\lib\site-packages\saspy\java\thirdparty\glassfish-corba-omgapi.jar;C:\Users\sam\.conda\envs\sastopython\lib\site-packages\saspy\java\thirdparty\glassfish-corba-orb.jar;C:\Users\sam\.conda\envs\sastopython\lib\site-packages\saspy\java\thirdparty\pfl-basic.jar;C:\Users\sam\.conda\envs\sastopython\lib\site-packages\saspy\java\thirdparty\pfl-tf.jar', 'pyiom.saspy2j', '-host', 'localhost', '-stdinport', '50352', '-stdoutport', '50353', '-stderrport', '50354', '-iomhost', 'odaws01-apse1-2.oda.sas.com;odaws02-apse1-2.oda.sas.com', '-iomport', '8591', '-user', 'xyz@gmail.com', '-lrecl', '1048576', '']

No SAS process attached. SAS process has terminated unexpectedly. Invalid response from SAS on inital submission. printing the SASLOG as diagnostic

Process finished with exit code 1

tomweber-sas commented 2 years ago

Ok, it looks like you have things configured correctly now. Seeing your config would be good, but what I see here seems ok. The error you're getting is:

We failed in getConnection
An exception was thrown during the encryption key exchange.

Which is documented here in number 9: https://sassoftware.github.io/saspy/troubleshooting.html#iom-specific-errors

What's odd is that you have the right level of java for this to work without needing these encryption jars. Unless they've upgraded SAS to M7, in which case that doesn't work anymore and you need the jars. You're connecting to the AP region, which I can't connect to so I can't try that out to tell. But, an easy fix should simply be to download the 3 jars from the link below and put them in your saspy deployment here: C:\Users\sam.conda\envs\sastopython\lib\site-packages\saspy\java\iomclient\

https://support.sas.com/downloads/package.htm?pid=2494

Try that and see if you can connect. Then, after you do connect, can you submit your SASsession object to print out some info for me; I'll be able to see what version of SAS is on there along with other info.

sas = saspy.SASsession() sas # or print(sas) if it's running as a batch job

>>> sas = saspy.SASsession(cfgname='oda')
SAS Connection established. Subprocess id is 36151

>>> sas
Access Method         = IOM
SAS Config name       = oda
SAS Config file       = /opt/tom/github/saspy/saspy/sascfg_personal.py
WORK Path             = /saswork/SAS_workDA80000189C3_odaws04-usw2.oda.sas.com/SAS_workC241000189C3_odaws04-usw2.oda.sas.com/
SAS Version           = 9.04.01M6P11072018
SASPy Version         = 4.3.1
Teach me SAS          = False
Batch                 = False
Results               = Pandas
SAS Session Encoding  = utf-8
Python Encoding value = utf_8
SAS process Pid value = 100803

>>>

Thanks, Tom

Samuelnikhade commented 2 years ago

Access Method = IOM SAS Config name = oda SAS Config file = C:\Users\sam\Anaconda3\envs\sastopy\lib\site-packages\saspy\sascfg_personal.py WORK Path = /saswork/SAS_work6AFB0001CF1A_odaws01-apse1-2.oda.sas.com/SAS_work2ABB0001CF1A_odaws01-apse1-2.oda.sas.com/ SAS Version = 9.04.01M6P11072018 SASPy Version = 4.3.1 Teach me SAS = False Batch = False Results = Pandas SAS Session Encoding = utf-8 Python Encoding value = utf-8 SAS process Pid value = 118554

Samuelnikhade commented 2 years ago

Jar file worked, Thanks