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

Issue connecting to the remote server #572

Closed martadenisiuk closed 5 months ago

martadenisiuk commented 5 months ago

I cannot connect to the remote server. This is my code:

SAS_config_names=['default']

SAS_config_options = {'lock_down': False,
                      'verbose'  : True,
                      'prompt'   : True
                     }

cpl = ";C:\\Program Files\\SASHome\\SASDeploymentManager\\9.4\\products\\deploywiz__94554__prt__xx__sp0__1\\deploywiz\\sas.svc.connection.jar"
cpl += ";C:\\Program Files\\SASHome\\SASDeploymentManager\\9.4\\products\\deploywiz__94554__prt__xx__sp0__1\\deploywiz\\log4j.jar"
cpl += ";C:\\Program Files\\SASHome\\SASDeploymentManager\\9.4\\products\\deploywiz__94554__prt__xx__sp0__1\\deploywiz\\sas.security.sspi.jar"
cpl += ";C:\\Program Files\\SASHome\\SASDeploymentManager\\9.4\\products\\deploywiz__94554__prt__xx__sp0__1\\deploywiz\\sas.core.jar"
cpl += ";C:\\Users\\AppData\\Roaming\\Python\\Python38\\site-packages\\saspy\\java\\saspyiom.jar"
cpl += ";C:\\Users\\AppData\\Roaming\\Python\\Python38\\site-packages\\saspy\\java\\thirdparty\\glassfish-corba-internal-api.jar"
cpl += ";C:\\Users\\AppData\\Roaming\\Python\\Python38\\site-packages\\saspy\\java\\thirdparty\\glassfish-corba-omgapi.jar"
cpl += ";C:\\Users\\AppData\\Roaming\\Python\\Python38\\site-packages\\saspy\\java\\thirdparty\\glassfish-corba-orb.jar"
cpl += ";C:\\Users\\AppData\\Roaming\\Python\\Python38\\site-packages\\saspy\\java\\thirdparty\\pfl-basic.jar"
cpl += ";C:\\Users\\AppData\\Roaming\\Python\\Python38\\site-packages\\saspy\\java\\thirdparty\\pfl-tf.jar"

default  = {'java'      : 'java',
               'iomhost'   : XXX, 
               'iomport'   : 8592,
               'omruser' : YYY,
               'omrpw' : ZZZ,
            'classpath' : cpl,
            }

The error that pops up is: Using SAS Config named: default We failed in getConnection The application could not log on to the server XXX. 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 java with the following parameters:['java', '-classpath', ';C:\Program Files\SASHome\SASDeploymentManager\9.4\products\deploywiz94554prtxxsp01\deploywiz\sas.svc.connection.jar;C:\Program Files\SASHome\SASDeploymentManager\9.4\products\deploywiz94554prtxxsp01\deploywiz\log4j.jar;C:\Program Files\SASHome\SASDeploymentManager\9.4\products\deploywiz94554prtxxsp01\deploywiz\sas.security.sspi.jar;C:\Program Files\SASHome\SASDeploymentManager\9.4\products\deploywiz94554prtxxsp01\deploywiz\sas.core.jar;C:\Users\AppData\Roaming\Python\Python38\site-packages\saspy\java\saspyiom.jar;C:\Users\AppData\Roaming\Python\Python38\site-packages\saspy\java\thirdparty\glassfish-corba-internal-api.jar;C:\Users\AppData\Roaming\Python\Python38\site-packages\saspy\java\thirdparty\glassfish-corba-omgapi.jar;C:\Users\AppData\Roaming\Python\Python38\site-packages\saspy\java\thirdparty\glassfish-corba-orb.jar;C:\Users\AppData\Roaming\Python\Python38\site-packages\saspy\java\thirdparty\pfl-basic.jar;C:\Users\AppData\Roaming\Python\Python38\site-packages\saspy\java\thirdparty\pfl-tf.jar; 'pyiom.saspy2j', '-host', 'localhost', '-stdinport', '58612', '-stdoutport', '58613', '-stderrport', '58614', '-iomhost', XXX, '-iomport', '8592', '-user', YYY, '-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:\Users\AppData\Roaming\Python\Python38\site-packages\IPython\core\interactiveshell.py", line 3437, in run_code exec(code_obj, self.user_global_ns, self.user_ns) File "", line 1, in sas = saspy.SASsession(cfgfile='C:/Users/' + os.getlogin() + '/python/sascfg_personal.py.py') File "C:\Users\AppData\Roaming\Python\Python38\site-packages\saspy\sasbase.py", line 537, in init self.pyenc = sas_encoding_mapping[self.sascei] KeyError: 'No SAS process attached. SAS process has terminated unexpectedly.'

From sassoftware.troubleshooting I understand that the problem is with IOM, right? Each of the given solutions does not work in my case. I'm sure I entered the correct omruser and omerpw. The problem is with a specific server, the connection to another server works. I saw that in this case there was the same problem: issue 441 but I don't think that's the reason why it doesn't work for me, because I tried to connect via a different network. I tried to look through the internal Saspy library scripts, where the error is indicated, but I don't know what I could manually rewrite to my script and change to make it work.

Sas is also installed on the remote server.

tomweber-sas commented 5 months ago

Hey, I'm a little confused by the messages you show at the beginning:

Using SAS Config named: default
SAS Connection established. Subprocess id is 30132
No encoding value provided. Will try to determine the correct encoding.
Setting encoding to utf_8 based upon the SAS session encoding value of utf-8.
sas = saspy.SASsession(cfgfile='sascfg_personal.py.')
Using SAS Config named: default
We failed in getConnection
The application could not log on to the server XXX. No server is available at that port on that machine.

The first few lines show a connection being established, but then you have a sas = saspy.SAsession() and after that you the failure due to the host/port not being correct. Where did the first set of lines come from that imply it worked?

Regardless, you shouldn't have that classpath in your config. So that the first problem I would fix and see if that makes any difference. What version of SASPy are you using? Needing to specify the classpath in the config was removed years ago https://sassoftware.github.io/saspy/configuration.html#attn-as-of-saspy-version-3-3-3-the-classpath-is-no-longer-required-in-your-configuration-file

As for the error about there not being a server for the host and port provided, can you see the host/port in metadata for this server? You can use SMC or proc IOMOPERATE to see the configuration for the object spawner and workspace server you're trying to connect to.

martadenisiuk commented 5 months ago

Hey,

Hey, I'm a little confused by the messages you show at the beginning:

Using SAS Config named: default
SAS Connection established. Subprocess id is 30132
No encoding value provided. Will try to determine the correct encoding.
Setting encoding to utf_8 based upon the SAS session encoding value of utf-8.
sas = saspy.SASsession(cfgfile='sascfg_personal.py.')
Using SAS Config named: default
We failed in getConnection
The application could not log on to the server XXX. No server is available at that port on that machine.

The first few lines show a connection being established, but then you have a sas = saspy.SAsession() and after that you the failure due to the host/port not being correct. Where did the first set of lines come from that imply it worked?

Sorry, my mistake, the first four lines were about a different server. I've already corrected it.

Regardless, you shouldn't have that classpath in your config. So that the first problem I would fix and see if that makes any difference. What version of SASPy are you using? Needing to specify the classpath in the config was removed years ago https://sassoftware.github.io/saspy/configuration.html#attn-as-of-saspy-version-3-3-3-the-classpath-is-no-longer-required-in-your-configuration-file

So, my original script did not include a classpath. I added this after searching for answers to other people's problems. Anyway, without classpath it didn't work either.

As for the error about there not being a server for the host and port provided, can you see the host/port in metadata for this server? You can use SMC or proc IOMOPERATE to see the configuration for the object spawner and workspace server you're trying to connect to.

This was very helpful! It turned out that I used omrhost as iomhost, not object spawner name. To connect via SAS Enterprise Guide, I use omrhost - that's my mistake. I didn't know there was a difference. It worked without having to add the appserver variable. Thanks very much for your help

tomweber-sas commented 5 months ago

So, are you up and running? It sounds like it. That's great if so. I don't understand the part about you having to code classpath, what version of SASPy are you using? Yes, EG connects to the Metadata Server as well as to a workspace server (via object spawner). So there are 2 different sets of host/ports it ends up using. The Profile in EG is configured to the Metadata Server, which is the first set you notice.

Let me know if there's anything else or if you're good and want to close this!

Thanks, Tom

martadenisiuk commented 5 months ago

So, are you up and running? It sounds like it. That's great if so.

Yes, it works :)

I don't understand the part about you having to code classpath, what version of SASPy are you using?

I have a 3.6.6 version. I know, that I don't need to specify classpath - it was just a form of experiment because after long hours I didn't know what I could do next. In final version of the script I don't have a classpath.

So there are 2 different sets of host/ports it ends up using. The Profile in EG is configured to the Metadata Server, which is the first set you notice.

Let me know if there's anything else or if you're good and want to close this!

Good to know and thanks again! That's all I wanted to know

tomweber-sas commented 5 months ago

Good deal! Let me know if you need anything else!