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

Access problems in a Windows / Windows environment #421

Closed matsvitt closed 2 years ago

matsvitt commented 2 years ago

Hi there,

I am trying to access a SAS Server on Windows from a Windows CLient:

my sascfg_personal.py is

cxs= {
            'authkey' : 'c_user',
            'java'      : "C:\\ProgramData\\Oracle\\Java\\javapath\\java.exe",
            'iomhost'   : 'myiomhost',
            'iomport'   : 8591,
            'appserver' : "SASApp - Workspace Server"      
           }

I have an _authinfo file

but when I run a login attempt like this (java direct command):


Attempted to run program C:\ProgramData\Oracle\Java\javapath\java.exe with the following parameters:['C:\\ProgramData\\Oracle\\Java\\javapath\\java.exe', '-classpath', 'C:\\localapp\\appsx64\\Miniconda3\\lib\\site-packages\\saspy\\java\\saspyiom.jar;C:\\localapp\\appsx64\\Miniconda3\\lib\\site-packages\\saspy\\java\\iomclient\\log4j-1.2-api-2.12.1.jar;C:\\localapp\\appsx64\\Miniconda3\\lib\\site-packages\\saspy\\java\\iomclient\\log4j-api-2.12.1.jar;C:\\localapp\\appsx64\\Miniconda3\\lib\\site-packages\\saspy\\java\\iomclient\\log4j-core-2.12.1.jar;C:\\localapp\\appsx64\\Miniconda3\\lib\\site-packages\\saspy\\java\\iomclient\\sas.security.sspi.jar;C:\\localapp\\appsx64\\Miniconda3\\lib\\site-packages\\saspy\\java\\iomclient\\sas.core.jar;C:\\localapp\\appsx64\\Miniconda3\\lib\\site-packages\\saspy\\java\\iomclient\\sas.svc.connection.jar;C:\\localapp\\appsx64\\Miniconda3\\lib\\site-packages\\saspy\\java\\iomclient\\sas.rutil.jar;C:\\localapp\\appsx64\\Miniconda3\\lib\\site-packages\\saspy\\java\\iomclient\\sas.rutil.nls.jar;C:\\localapp\\appsx64\\Miniconda3\\lib\\site-packages\\saspy\\java\\iomclient\\sastpj.rutil.jar;C:\\localapp\\appsx64\\Miniconda3\\lib\\site-packages\\saspy\\java\\thirdparty\\glassfish-corba-internal-api.jar;C:\\localapp\\appsx64\\Miniconda3\\lib\\site-packages\\saspy\\java\\thirdparty\\glassfish-corba-omgapi.jar;C:\\localapp\\appsx64\\Miniconda3\\lib\\site-packages\\saspy\\java\\thirdparty\\glassfish-corba-orb.jar;C:\\localapp\\appsx64\\Miniconda3\\lib\\site-packages\\saspy\\java\\thirdparty\\pfl-basic.jar;C:\\localapp\\appsx64\\Miniconda3\\lib\\site-packages\\saspy\\java\\thirdparty\\pfl-tf.jar', 'pyiom.saspy2j', '-host', 'localhost', '-stdinport', '53153', '-stdoutport', '53154', '-stderrport', '53155', '-appname', "'SASApp - Workspace Server'", '-iomhost', 'myiomhost', '-iomport', '8591', '-user', 'user', '-lrecl', '1048576', '']

I get:

java.net.ConnectException: Connection refused: connect
        at java.net.DualStackPlainSocketImpl.connect0(Native Method)
        at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
        at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
        at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
        at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
        at java.net.PlainSocketImpl.connect(Unknown Source)
        at java.net.SocksSocketImpl.connect(Unknown Source)
        at java.net.Socket.connect(Unknown Source)
        at java.net.Socket.connect(Unknown Source)
        at java.net.Socket.<init>(Unknown Source)
        at java.net.Socket.<init>(Unknown Source)
        at pyiom.saspy2j.main(saspy2j.java:175)
Exception in thread "main" java.lang.NullPointerException
        at pyiom.saspy2j.main(saspy2j.java:184)

Do I miss something? I am wondering why in the command line the "-user user" is correct.

Any help is highly appreciated.

tomweber-sas commented 2 years ago

What was the actual error? The information before the line saying 'Attempted to run ....' that you pasted above, has the rest of the information and the actual error in it. I can't tell what the problem was with that part of the log. The error you got trying to run the command yourself is correct. That can be helpful for certain problems, but probably not whatever the error is that you're getting. Getting the connection refused shows that your classpath is ok and that java was found and came up, ... But that's as much as that tells. If you show me the whole log from your attempt, I can see what error it is and get you going! Tom

matsvitt commented 2 years ago

OK I got it solved, the problem was that the command line used the wrong user. But why? since I had it coded in the _authinfo file (using the correct syntax).

These two lines in sasioiom.py seem to return "user" and "password" instead of the actual user - strange:

user = line.partition('user')[2].lstrip().partition(' ')[0].partition('\n')[0]
pw   = line.partition('password')[2].lstrip().partition(' ')[0].partition('\n')[0]

So I commented that out and set ormuser/ormpw directly in sascfg_personal.py (which is discouraged). Also set "sspi=False" there. Need to investigate more on this.

thanks for answering so quickly. Matthias

tomweber-sas commented 2 years ago

Well, that implies that the format of what you have in the authinfo file doesn't match what's expected.

tomweber-sas commented 2 years ago

Hey, I thought about this a bit ago and realized it's a parsing issue on my end. I didn't take into account having user as part of the key, which is throwing the parsing off. Thanks for following up w/ they creds being 'user' and 'password' as that made it apparent. I just tweaked the code to account for that, so if you can pull from main, you can try this back the way you had it and see that it's fixed and works for you (I expect, and hope). Can you give that a try?

Thanks, Tom

matsvitt commented 2 years ago

Thanks for your help. Of course I will try it.

Matthias

On 17. Nov 2021, at 06:47, Tom Weber @.***> wrote:

Hey, I thought about this a bit ago and realized it's a parsing issue on my end. I didn't take into account having user as part of the key, which is throwing the parsing off. Thanks for following up w/ they creds being 'user' and 'password' as that made it apparent. I just tweaked the code to account for that, so if you can pull from main, you can try this back the way you had it and see that it's fixed and works for you (I expect, and hope). Can you give that a try?

Thanks, Tom

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/sassoftware/saspy/issues/421#issuecomment-971211529, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAGVDPHASNL6FXDR7747SKDUMM6YBANCNFSM5IEFQ42A. Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

tomweber-sas commented 2 years ago

Hey @matsvitt did you have a chance to validate this? I've been busy with other things, but I have this and another fix that I will build into a new production version if this is good for you. The other fix has been validated so if this is good, I'll see about getting these into production. Thanks! Tom

matsvitt commented 2 years ago

Hi there,

I wish I could test your version so easily as you do the fixes… however I am working in a setting where I need to request every (!) new version of any sas package..and this is a long process. So unfortunately this will take time.

Matthias

On 30. Nov 2021, at 20:05, Tom Weber @.***> wrote:

Hey @matsvitt https://github.com/matsvitt did you have a chance to validate this? I've been busy with other things, but I have this and another fix that I will build into a new production version if this is good for you. The other fix has been validated so if this is good, I'll see about getting these into production. Thanks! Tom

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/sassoftware/saspy/issues/421#issuecomment-982931565, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAGVDPGRP4SJI2GGEQD5ZU3UOUN73ANCNFSM5IEFQ42A. Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

tomweber-sas commented 2 years ago

Oh, ok, no problem! I tested it, it's good. I just like to have the people who report the problem verify it on their side, so it's not a 'works for me on my machine' kind of a deal. I'll just build the new version, probably tomorrow, and then you can request it once it's the new production release. I post here once it's out there. Thanks! Tom

matsvitt commented 2 years ago

That sounds good. I am really sorry not to be alle to support you here - but I have NGO Choice here. :)

Best regards

Matthias

tomweber-sas commented 2 years ago

Really, it's no problem at all. This was a trivial fix and I know it's fine. And, I just built the new version, so it's here and on Pypi as v3.7.6; current version on pypi, so it's the default you'd get now. Conda will build this over the next few hours, as their bot will find it and schedule a build. So that won't be there as the current till after that and then I merge it in. Either way, I bet that'll still be sooner than you can get a request in and get it approved, haha :) I'll go ahead and close this, but just let me know if there's any issue or you have any other problems or questions!

Thanks, Tom