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
367 stars 149 forks source link

SASPY ODA configuration issue #441

Closed sam-as closed 2 years ago

sam-as commented 2 years ago

Describe the bug I am unable to connect to SAS ODA. I have gone through the documentation, tried every fix available in the forum but was unable to connect to SAS.

To Reproduce

import pandas as pd 
import numpy as np
import saspy as sp

logging to a sas session sps=sp.SASsession()

Running this fetches the following error message.

Using SAS Config named: oda

We failed in getConnection
The application could not log on to the server "odaws02-apse1.oda.sas.com:8591". No server is available at that port on that machine.

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\\aviks\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\saspy\\java\\saspyiom.jar;C:\\Users\\aviks\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\saspy\\java\\iomclient\\log4j-1.2-api-2.12.4.jar;C:\\Users\\aviks\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\saspy\\java\\iomclient\\log4j-api-2.12.4.jar;C:\\Users\\aviks\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\saspy\\java\\iomclient\\log4j-core-2.12.4.jar;C:\\Users\\aviks\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\saspy\\java\\iomclient\\sas.security.sspi.jar;C:\\Users\\aviks\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\saspy\\java\\iomclient\\sas.core.jar;C:\\Users\\aviks\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\saspy\\java\\iomclient\\sas.svc.connection.jar;C:\\Users\\aviks\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\saspy\\java\\iomclient\\sas.rutil.jar;C:\\Users\\aviks\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\saspy\\java\\iomclient\\sas.rutil.nls.jar;C:\\Users\\aviks\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\saspy\\java\\iomclient\\sastpj.rutil.jar;C:\\Users\\aviks\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\saspy\\java\\thirdparty\\glassfish-corba-internal-api.jar;C:\\Users\\aviks\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\saspy\\java\\thirdparty\\glassfish-corba-omgapi.jar;C:\\Users\\aviks\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\saspy\\java\\thirdparty\\glassfish-corba-orb.jar;C:\\Users\\aviks\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\saspy\\java\\thirdparty\\pfl-basic.jar;C:\\Users\\aviks\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\saspy\\java\\thirdparty\\pfl-tf.jar', 'pyiom.saspy2j', '-host', 'localhost', '-stdinport', '62198', '-stdoutport', '62199', '-stderrport', '62200', '-iomhost', 'odaws01-apse1.oda.sas.com;odaws02-apse1.oda.sas.com', '-iomport', '8591', '-user', 'avik.sam@iitb.ac.in', '-lrecl', '1048576', '']

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

Traceback (most recent call last):
  File "c:\-\sas_conversion.py", line 10, in <module>
    sps=sp.SASsession()
  File "C:\Users\aviks\AppData\Local\Programs\Python\Python310\lib\site-packages\saspy\sasbase.py", line 590, in __init__
    self.pyenc = sas_encoding_mapping[self.sascei]
KeyError: 'No SAS process attached. SAS process has terminated unexpectedly.'`

This is my sascfg_personal.py file:

SAS_config_names=['oda']
oda = {'java' : "C:\\Program Files (x86)\\Common Files\\Oracle\\Java\\javapath\\java.exe",
#Asia Pacific Home Region
'iomhost' : ['odaws01-apse1.oda.sas.com','odaws02-apse1.oda.sas.com'],
'iomport' : 8591,
'authkey' : 'oda',
'encoding' : 'utf-8'
}`

This is my _authinfo oda user xxx@---.ac.in password ************

This is the part of the sascfg.py where I have changed the JAVA directory.

iomlinux = {'java'      : '/usr/bin/java',
            'iomhost'   : 'linux.iom.host',
            'iomport'   : 8591,
            }           

iomwin   = {'java'      : 'C:\\Program Files (x86)\\Common Files\\Oracle\\Java',
            'iomhost'   : 'windows.iom.host',
            'iomport'   : 8591,
            }

winlocal = {'java'      : 'C:\\Program Files (x86)\\Common Files\\Oracle\\Java',
            'encoding'  : 'windows-1252',
            }

winiomlinux = {'java'   : 'C:\\Program Files (x86)\\Common Files\\Oracle\\Java',
            'iomhost'   : 'linux.iom.host',
            'iomport'   : 8591,
            }

winiomwin  = {'java'    : 'C:\\Program Files (x86)\\Common Files\\Oracle\\Java',
            'iomhost'   : 'windows.iom.host',
            'iomport'   : 8591,
            }

winiomIWA  = {'java'    : 'C:\\Program Files (x86)\\Common Files\\Oracle\\Java',
            'iomhost'   : 'windows.iom.host',
            'iomport'   : 8591,
            'sspi'      : True
            }

Desktop:

 - OS: Windows 11 Home
 - SASPy Version: 4.1.0
 - Python Version:  3.10.2

I would really appreciate any help.

tomweber-sas commented 2 years ago

Hey, sorry to be so slow responding, I've been on vacation since last week. Just back today and trying to get caught up. So, the error message: The application could not log on to the server "odaws02-apse1.oda.sas.com:8591". No server is available at that port on that machine. Identifies that there's not an object spawner on either of those nodes. Which I've double checked against the doc, and they are specified correctly, based upon the doc. Since I'm in the US region, if I try to connect to those (either Asia Pacific or European), I get a slightly different error; I expect because I can't reach those, but I'm not sure at the moment. I get The application could not log on to the server "odaws02-xxxx.oda.sas.com:8591". The load balancing object spawner timed out. That doesn't really prove anything, and I don't know why you would get an error that there's no server there, unless maybe there was an outage? I'll contact someone here that can check on why this might happen and let you know what I find. I was able to connect to the US one (which is the only ones I believe I'm able to connect to). Thanks, Tom

tomweber-sas commented 2 years ago

Hey @sam-as I checked w/ the ODA folks here and they say the AP region server are up at those addresses. They also say that they are down for maintenance once a week at 2:00AM local time. There's also a link for checking on the status; it also has a link for getting help w/ your profile or logon/registration problems. I'm assuming you've tried this other than at 2:00AM on whatever day the servers were down, but can you try it again and see what you get? The other thought about that error is that I've seen that for cases where DNS can't resolve the host name. I'm not sure where you're trying to connect from, but can you check to see (from wherever you're running python) to see if that hostname is being resolved?

tom64-5> nslookup odaws02-apse1.oda.sas.com
Server:         10.19.1.23
Address:        10.19.1.23#53

Non-authoritative answer:
Name:   odaws02-apse1.oda.sas.com
Address: 54.251.250.202

If it can't find it, then that's the problem. Else, we'll keep digging.

Thanks, Tom

sam-as commented 2 years ago

Hey Tom, No worries about the delay due to vacation. Hope that You had a lively one.

About the issue, I have checked the status of the AP server that is normal at the time (Feb 17, 2022 09:47 UTC). I also checked whether the hostname is resolved or not by using the Python Library socket on VS Code. I am obtaining the following results:

import socket 

address='odaws01-apse1.oda.sas.com'
print(f'Address :{socket.gethostbyname(address)}')                     
Address :54.251.250.201

address2='odaws02-apse1.oda.sas.com' 
print(f'Address :{socket.gethostbyname(address2)}') 
Address :54.251.250.202

Best, Avik

tomweber-sas commented 2 years ago

Thanks! I did have a good one, was scuba diving! So, everything above looks good; meaning I don't see anything obviously wrong. However, I also don't see anything in the object spawner logs that has your id in it. I see mine, for the failures I get when trying to connect to these and I get the error I get (spawner timed out). That seems like the problem is on the client side, but I can't pinpoint why that would be. What version of java is that you're running? You can do java -version to see. Also, what happens if you try to connect to either of the other regions (US or EUR)?

sam-as commented 2 years ago

I am using the following versions:

java version "1.8.0_321"
Java(TM) SE Runtime Environment (build 1.8.0_321-b07)
Java HotSpot(TM) 64-Bit Server VM (build 25.321-b07, mixed mode)

And, I tried connecting to the US Server. I'm getting the same error.

Using SAS Config named: oda
We failed in getConnection
The application could not log on to the server "odaws04-usw2.oda.sas.com:8591". No server is available at that port on that machine.

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.
sam-as commented 2 years ago

I think I identified the problem. While I am connecting through the campus WiFI/ Ethernet, I am getting these error messages, but if I connect my system with the hotspot of my mobile internet connection (a private telecom operator), I am able to connect to the server.

# while using the mobile hotspot
Using SAS Config named: oda
SAS Connection established. Subprocess id is 10020

Any workaround on this so that I can connect using the campus WiFI/ ethernet? I tried setting up the proxy manually, but it does not work.

tomweber-sas commented 2 years ago

Hey, great job identifying that! I see your connection now on AP, and an attempt that failed on US (you tried while on cell, and got the same error I was getting, I assume). This still seems to me to be a DSN issue while on your campus WiFi; it's that it's not resolving the host name or resolving to the wrong IP, or possibly being blocked for some reason. At least that's what it seems like to me. The error and lack of any actual connection attempt on the server side (when you get that error; nothing in the logs showing it ever got there) implies it's on the client end.

Can you try replacing the host names in your iomhost list with the ip addresses (as strings still) and see if that makes any difference? sas = saspy.SASsession(iomhost=['54.251.250.201','54.251.250.202']) If it's a DNS issue, that should hopefully get around it. Also, as diagnostics, can you do the host lookup for the host names for both cases to see if it's different (wifi vs cell)? The other way I can think of would be to add the hostnames and ip's to your etc/hosts file, but I think that's going to end up being the same thing as just using the IP addresses instead of the host names; but just another way to do it.

Let's see what all of this shows, and if using the IP works, then at least you'll be able to use wifi instead of eating your cell minutes! Tom

sam-as commented 2 years ago

Hi. When I included the IP addresses as strings as mentioned above, it returned Parameter 'iomhost' passed to SAS_session was ignored due to configuration restriction.

I updated the sascfg_personal file by replacing the server address with the IP addresses but I received this error while using the WIFI:

We failed in getConnection
The application could not log on to the server "ec2-54-251-250-202.ap-southeast-1.compute.amazonaws.com:8591". No server is available at that port on that machine.

SAS process has terminated unexpectedly. RC from wait was: 4294967290

It worked on the cell connection after an initial hiccup. Strangely, the host lookup for both cell and wifi returned the same addresses for both the servers.

tomweber-sas commented 2 years ago

Ok, well that still helps narrow down some things. So, it's not a DNS issue, as it's resolving to the correct IP and hostname, when using an IP. And that's working regardless of your connection. Also, I tried using a name that doesn't resolve, and it produces a different error: The application could not log on to the server "xxx.yyy:8591". The machine name is not valid. All this leaves me with is that there's some firewall constraint of something else blocking access to this route when you're on your school WiFi. The attempts, whether successful or failures (when you tried US instead of AP), were logged in the object spawner logs, when you were on your Cell connection. but there were no records at all of any attempts when you were on School WiFi. So, that means that, since the address was being resolved correctly, that there was no connection making it to the object spawner machines. Which only leaves something on your side that was keeping that from succeeding. Thus some filrewall setting or some other restriction for accessing that system. Is there a resource you can contact about the school WiFi to see if there's something blocking access? Or can you see any firewall settings on your computers when you're using that WiFi to see if it's being blocked? Is windows is turning on it's firewall when you connect to the WiFi, but not when you use the Cell hotspot/wifi?

sam-as commented 2 years ago

Hi, thank you. I have contacted the network administrators for resolving this and changing the firewall settings. I was able to access the SAS Studio online on the school Wi-Fi. Clearly, the firewall is blocking access selectively on the python environment. I will get back to you as soon as I hear from them.

tomweber-sas commented 2 years ago

Hey, just checking in. Did you ever get this figured out w/ the admins?

sam-as commented 2 years ago

Hey, thank you for your help. The admins are still figuring out, and till then, I will be using the web client for SAS. Meanwhile, I am closing this issue. Thanks again! :)

sam-as commented 2 years ago

Hey, I was able to log on to the SAS server using the campus network. Never thought that a firewall would be the problem. :) Thanks.

tomweber-sas commented 2 years ago

Great! That was the problem; you got it fixed? Thanks for letting me know. Let me know if there's anything else you need! Tom