SAP / node-rfc

Asynchronous, non-blocking SAP NW RFC SDK bindings for Node.js
Apache License 2.0
251 stars 73 forks source link

SAP NWRFC SDK on Darwin works for single processes only #143

Closed bsrdjan closed 3 years ago

bsrdjan commented 4 years ago

After Apple security policy elevated, patched SAP NWRFC SDK does not work any more on Darwin 10.15.4, see #140.

Un-patched SDK, from SAP Support Portal, can be used with DYLD_FALLBACK_LIBRARY_PATH env variable set to SDK binaries path ($SAPNWRFC_HOME/lib folder) and it works for single process only.

Possible solutions are investigated with SAP NWRFC SDK experts.

Existing users

If your SAP NWRFC SDK and node-rfc already work on Darwin, you can upgrade Darwin and node-rfc, keeping the full functionality. If you upgrade SAP NWRFC SDK, it works in single process apps only.

New users

Install the SAP NWRFC SDK and set DYLD variable, like described in README. It works in single process apps only until this issue closed.

geekhunger commented 4 years ago

@bsrdjan I installed the nwrfcsdk, then set the paths as you've stated. I now no longer get the codesign error but somethings still not right, because I get this error "Could not open the ICU common library". Could you explain what's missing, please?

Bildschirmfoto 2020-05-08 um 12 57 36

EDIT: actually got this working, when I set export SAPNWRFC_HOME=/usr/local/sap/nwrfcsdk and also exportDYLD_LIBRARY_PATH=$SAPNWRFC_HOME/lib:$DYLD_LIBRARY_PATH

PS: If someone comes across this - if you have troubles to set these variables permanently then put the above export commands into sudo nano ~/.zprofile. As stated here https://stackoverflow.com/questions/56784894/macos-catalina-10-15beta-why-is-bash-profile-not-sourced-by-my-shell apple changed the default shell (before that file was ~/.profile)

bsrdjan commented 4 years ago

Thank you @jack0088. Please consider that DYLD* variables are purged in child processes, no matter if set in shell, node app etc. I came across that after having a simple node script working stand-alone with DYLD and failing when executed by jest test framework. Setting the DYLD variables in the node app itself, just before loading the lib, did not help.

bsrdjan commented 4 years ago

Did you try using previous, PL5 NWRFC SDK version, with the patch, until this issue solved?

PaulWieland commented 4 years ago

to people affected by this, I would recommend using Docker as it specifically addresses issues like this.

@bsrdjan I'm working on getting a light docker container working with node and node-rfc, if there is interest in SAP including or publishing this dockerfile I will share.

bsrdjan commented 4 years ago

Yes. that would be another nice workaround for users affected with Darwin/PL6 issue, we still work on. Would you publish here, inside the new docker folder for example, as a contributor, or on docker hub?

PaulWieland commented 4 years ago

I would suggest publishing the dockerfile here on github and the built docker image on dockerhub. It's not something I would publish directly with my user account as technically I would be redistributing the precompiled nwsdk libraries. I'm sure that violates a EULA somewhere...

guptar85 commented 4 years ago

@bsrdjan @PaulWieland - I am using below Docker File. My use-case was different as I want to call SAP from Pivotal Cloud Foundry so I hosted container on PKS. I guess below DockerFile will work for any scenario.

Dockerfile

#Create a layer from the node:lts Docker image. FROM node:lts

#Copying SDK from local to the desired location ADD nwrfcsdk /usr/local/sap/nwrfcsdk

#Settign environment variable as mentioned in the document ENV SAPNWRFC_HOME=/usr/local/sap/nwrfcsdk

RUN echo /usr/local/sap/nwrfcsdk/lib > /etc/ld.so.conf.d/nwrfcsdk.conf && ldconfig

#Changing the Working directory WORKDIR /usr/app

#Copying the source code to /usr/app/src from current directory COPY src/ .

#Running NPM install RUN npm i

#Exposing the PORT EXPOSE 3000

#Running the application CMD [ "node", "index.js" ]

.dockerignore

.git .gitignore **/node_modules

Thanks!

PaulWieland commented 4 years ago

Thanks for sharing your dockerfile @guptar85. The node:lts base image is quite large at nearly 1GB.

I'm trying to reduce the image size by building off of one of the really small base images for node (Alpine Linux is 5mb, and alpine + node is ~40mb for example). It's proving to be a challenge because the NWRFCSDK doesn't work in MUSL based linux environments. I am making progress with some of the other "slim" glibc based images.

I still think it should be possible to get a working node + node-rfc base image that is in the 200mb or less range, but we will see :)

guptar85 commented 4 years ago

@PaulWieland - Yes initially I tried with Alpine but it didn't work with NWRFCSDK. If you change the version of Node from lts to lts-slim in Dockerfile and size will reduce to 377MB (where lts-slim is 142 MB and NWRFCK folder is 50MB and remaining is my src folder along with node_modules)

Below screenshot is few comparisons with different tag's I tried with the dockerfile

image

Thanks!

stesap commented 4 years ago

just to be mentioned, there is also a official Dockerfile avail. by SAP https://github.com/SAP/devops-docker-images/tree/master/node-rfc

ankri commented 4 years ago

Is there a recommended way to get the PL 5 Version of the NWRFCSDK for Catalina? I am only able to download the PL6 from the Launchpad.

bsrdjan commented 4 years ago

Sorry, the PL5 is not available on SAP Support Portal.

bsrdjan commented 3 years ago

The release 2.2.0 with PL7 fixes this issue