SAP / node-rfc

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

Issue making connection to ABAP system with node-rfc #183

Closed h2plucifer closed 3 years ago

h2plucifer commented 4 years ago

Hi,

I have been getting error while utilizing node-rfc module to make connection to ABAP system & execute particular BAPI function.

I tried following for the execution:

My application is built with 32-bit node setup , so directly executing node-rfc code doesn't work & throws following error :

So i replaced the sapnwrfc.node with the 32-bit binary as found in the following link :

Now executing node-rfc code I don't get the initial error(invalid 32 bit application ) but getting following error :

Currently trying to execute following code : `

"use strict";

const Client = require("node-rfc").Client;
    const abapSystem = {
        user: "",
        passwd: "",
        ashost: "",
        sysnr: "00",
        client: "014",
        lang: "EN",
    };
const client = new Client(abapSystem);
client.connect(function (err) {
    if (err) return console.error("could not connect to server", err);
    const structure = {
        RFCINT4: 345,
        RFCFLOAT: 1.23456789,
        RFCCHAR4: "ABCD",
        RFCDATE: "20180625", 
    };
// ABAP table
let table = [structure];
   client.invoke(
        "STFC_STRUCTURE",
        { IMPORTSTRUCT: structure, RFCTABLE: table },
        function (err, res) {
            if (err)
                return console.error("Error invoking STFC_STRUCTURE:", err);
            console.log("STFC_STRUCTURE call result:",res);
        }
    );
});

`

Environment details :

Node version : v12.18.4 Node process.arch : ia32 Platform : Windows 10 64-bit node-rfc: 2.3.0

Please let me know if anyone have any solution or correction on my approach that needs to be done to run it successfully.

Thanks

bsrdjan commented 4 years ago

The 32 bit version was missing in latest release, now added: https://github.com/SAP/node-rfc/releases/tag/v2.3.0

The re-installation should fix the issue.

h2plucifer commented 4 years ago

Thanks for the quick response. Let me try this one .

h2plucifer commented 4 years ago

Hi @bsrdjan ,

I tried utilizing the shared packages but still I am not able to setup node-rfc (Previously I was able to install node-rfc using v14.15.0).

Please find the following details about my approach :

1. Currently testing in following environment & its not working with following error message :

Nodejs : v12.18.4 NPM : 6.14.6 Nodejs process.arch : ia32

Note : It fails to install node-rfc with following error (I tried both npm install node-rfc & custom package build but both fails for the mentioned node environment):

Following message(error) I get while trying npm install :

> node-rfc@2.3.0 install C:\Users\XXX\AppData\Local\X\XXX\Projects\11111\node_modules\bapi\node_modules\node-rfc
> prebuild-install --tag-prefix -r napi || cmake-js rebuild

prebuild-install WARN This package does not support N-API version undefined 
prebuild-install WARN install No prebuilt binaries found (target=undefined runtime=napi arch=ia32 libc= platform=win32)
[
  'C:\\Users\\XXX\\Documents\\node-v12.18.4-win-x86\\node.exe',
  'C:\\Users\\XXX\\AppData\\Local\\X\\XXX\\Projects\\11111\\node_modules\\bapi\\node_modules\\node-rfc\\node_modules\\cmake-js\\bin\\cmake-js',
  'rebuild'
]
info TOOL Using Visual Studio 16 2019 generator.
info CMD CLEAN
info RUN cmake -E remove_directory "C:\Users\XXX\AppData\Local\X\XXX\Projects\11111\node_modules\bapi\node_modules\node-rfc\build"
info CMD CONFIGURE
info RUN cmake "C:\Users\XXX\AppData\Local\X\XXX\Projects\11111\node_modules\bapi\node_modules\node-rfc" --no-warn- rfc/node_modules/cmake-js/lib/cpp/win_delay_load_hook.cc" -DNODE_RUNTIME="node" -DNODE_RUNTIMEVERSION="12.18.4" -DNODE_ARCH="ia32" -DCMAKE_JS_LIB="C:\Users\XXX\.cmake-js\node-ia32\v12.18.4\win-x86\node.lib" -DCMAKE_SHARED_LINKER_FLAGS="/DELAYLOAD:NODE.EXE /SAFESEH:NO"
Not searching for unused variables given on the command line.
-- Selecting Windows SDK version 10.0.18362.0 to target Windows 10.0.18363.
-- The C compiler identification is MSVC 19.27.29112.0

  Checking Build System
  Building Custom Rule C:/Users/XXX/AppData/Local/X/XXX/Projects/11111/node_modules/irpa_bap
  i/node_modules/node-rfc/CMakeLists.txt
  Client.cc
  nwrfcsdk.cc
  Pool.cc
  Throughput.cc
  Server.cc
  addon.cc
     Creating library C:/Users/XXX/AppData/Local/X/XXX/Projects/11111/node_modules/bapi
  /node_modules/node-rfc/build/Release/Xnwrfc.lib and object C:/Users/XXX/AppData/Local/X/XXX/Projects/11111/node_modules/bapi/node_modules/node-rfc/build/Release/Xnwrfc.exp
Client.obj : **error LNK2001: unresolved external symbol _RfcGetFunctionDesc@12 [C:\Users\XXX\AppData\Local\X\XXX\Projects\11111\node_modules\bapi\node_modules\node-rfc\build\Xnwrfc.vcxproj]
Client.obj : error LNK2001: unresolved external symbol _RfcResetServerContext@8 [C:\Users\XXX\AppData\Local\X\XXX\Projects\ 
11111\node_modules\bapi\node_modules\node-rfc\build\Xnwrfc.vcxproj]
11111\node_modules\bapi\node_modules\node-rfc\build\Xnwrfc.vcxproj]
nwrfcsdk.obj : error LNK2001: unresolved external symbol _RfcSetTime@16 [C:\Users\XXX\AppData\Local\X\XXX\Projects\11111\node_modules\bapi\node_modules\node-rfc\build\Xnwrfc.vcxproj]
nwrfcsdk.obj : error LNK2001: unresolved external symbol _RfcGetRcAsString@4** [C:\Users\XXX\AppData\Local\X\XXX\Projects\11111
ERR! OMG Process terminated: 1
npm WARN bapi@1.5.44 No description
npm WARN bapi@1.5.44 No repository field.
npm WARN bapi@1.5.44 No license field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-rfc@2.3.0 install: `prebuild-install --tag-prefix -r napi || cmake-js rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-rfc@2.3.0 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\XXX\AppData\Roaming\npm-cache\_logs\2020-11-12T11_15_00_525Z-debug.log

2. Also tried with following environment setup & it works fine:

node : v14.15.0 npm : v6.14.8 node process.arch : x64

For this node environment I used node-rfc source code v2.3.0 & tested both node-rfc-v2.3.0-napi-v7-win32-ia32.tar.gz & node-rfc-v2.3.0-napi-v7-win32-x64.tar.gz & they works fine with mentioned nodejs environment.

But my objective is to run node-rfc with the first environment( v12.8.4) & its not working for me.

Please let me know if you could provide your input to resolve the issue.

Thanks

bsrdjan commented 4 years ago

The package can be build only with N-API 7 node versions and it works for older node versions. The problem happens because the build from source starts and breaks on your N-API 6 node 12.18.4. I need more time to investigate why the build starts because N-API 7 binaries are backwards compatible and no re-build needed.

In the meantime:

If you can upgrade to 12.19.0 (N-API 7), the build from source should not start any more.

If upgrade is not an option, you can download and unpack the N-API 7 node-rfc binary and copy/paste the sapnwrfc.node to your node_modules/node-rfc/lib/binding/sapnwrfc.node.

h2plucifer commented 4 years ago

Hi @bsrdjan,

Thanks again for the update.

Nodejs upgrade would not possible for us as of now.

And regarding sapnwrfc.node copy/paste I have tried following approaches but still doesn't solve the issue:

  1. Since neither build nor npm install seems possible with v12.8.4 , I took the node-rfc installation from v14.15.0 & replaced sapnwrfc.node as suggested but still get the error: node-rfc\lib\binding\sapnwrfc.node is not a valid Win32 application.

  2. I took the shared node-rfc v2.3.0 (https://github.com/SAP/node-rfc/releases/tag/v2.3.0) & tried replacing sapnwrfc.node but still gets the same error.

Please do let me know if you find any other update on the issue & also meanwhile I will try to find some workaround for it.

Thanks

bsrdjan commented 4 years ago

Are you sure you tested with correct sapnwrfc.node because "not a valid Win32 application" looks like 64 bit binary on 32 bit system? I re-tested as follows:

  1. Installed node-rfc with node 14.15.0, this sapnwrfc.node installed without build from source

  2. Switched node version to 12.18.4 and all works fine, as shown in console log below

Could you please re-test? Just for any case, here the sapnwrfc.node.zip working on my Win32 test system with 12.18.4.

If you still get an error, please post the full installation log.

PS C:\src\node-rfc-test> nvm use 14.15.0 32
Now using node v14.15.0 (32-bit)
PS C:\src\node-rfc-test> npm i node-rfc

> node-rfc@2.3.0 preinstall C:\src\node-rfc-test\node_modules\node-rfc
> npm install cmake-js prebuild-install prebuild node-addon-api

npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142    
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
npm notice created a lockfile as package-lock.json. You should commit this file.
+ cmake-js@6.1.0
+ prebuild-install@5.3.6
+ prebuild@10.0.1
+ node-addon-api@3.0.2
added 252 packages from 232 contributors and audited 252 packages in 48.064s

9 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

> node-rfc@2.3.0 install C:\src\node-rfc-test\node_modules\node-rfc
> prebuild-install --tag-prefix -r napi || cmake-js rebuild

npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN node-rfc-test@1.0.0 No description
npm WARN node-rfc-test@1.0.0 No repository field.

+ node-rfc@2.3.0
added 3 packages from 66 contributors and audited 3 packages in 53.111s
found 0 vulnerabilities

PS C:\src\node-rfc-test> node -p "require('node-rfc').environment"
{
  platform: { name: 'win32', arch: 'ia32', release: '10.0.18363' },
  env: {
    SAPNWRFC_HOME: 'C:\\Tools\\nwrfcsdk-32',
    RFC_INI: '',
    nwrfcsdk_lib_on_path: true
  },
  versions: {
    node: '14.15.0',
    v8: '8.4.371.19-node.17',
    uv: '1.40.0',
    zlib: '1.2.11',
    brotli: '1.0.9',
    modules: '83',
    nghttp2: '1.41.0',
    napi: '7',
    llhttp: '2.1.3',
    openssl: '1.1.1g',
    cldr: '37.0',
    icu: '67.1',
    unicode: '13.0'
  noderfc: {
    version: '2.3.0',
    nwrfcsdk: { major: 7500, minor: 0, patchLevel: 5 }
  }
}

PS C:\src\node-rfc-test> nvm use 12.18.4 32
Now using node v12.18.4 (32-bit)
PS C:\src\node-rfc-test> node -p "require('node-rfc').environment"
{
  platform: { name: 'win32', arch: 'ia32', release: '10.0.18363' },
  env: {
    SAPNWRFC_HOME: 'C:\\Tools\\nwrfcsdk-32',
    RFC_INI: '',
    nwrfcsdk_lib_on_path: true
  },
  versions: {
    node: '12.18.4',
    v8: '7.8.279.23-node.39',
    uv: '1.38.0',
    zlib: '1.2.11',
    brotli: '1.0.7',
    ares: '1.16.0',
    modules: '72',
    nghttp2: '1.41.0',
    napi: '6',
    llhttp: '2.1.2',
    http_parser: '2.9.3',
    openssl: '1.1.1g',
    cldr: '37.0',
    icu: '67.1',
    tz: '2019c',
    unicode: '13.0'
  },
  noderfc: {
    version: '2.3.0',
    nwrfcsdk: { major: 7500, minor: 0, patchLevel: 5 }
  }
}
PS C:\src\node-rfc-test>
h2plucifer commented 4 years ago

HI @bsrdjan ,

Thanks for your information I am able to execute the required setup. From your input I could figure out that the issue was with node v14.15.0 (Mine was 64-bit) & SAP NW RFC SDK (which was also 64 bit.) Now all working fine.

Thanks for you time & help,

regards

bsrdjan commented 3 years ago

Keep open until the installation for lower nodejs versions fixed

h2plucifer commented 3 years ago

Hi @bsrdjan,

Recently I started getting this error message while trying to install node-rfc module ( Previously I was able to install without any issue) :

.......
.......
 Checking Build System
  Building Custom Rule C:/Users/XX/Documents/RFC/test2/node_modules/node-rfc/CMakeLists.txt
  Client.cc
C:\Users\XX\Documents\RFC\test2\node_modules\node-rfc\node_modules\node-addon-api\napi-inl.h(1575,24): error C386
1: 'napi_is_detached_arraybuffer': identifier not found [C:\Users\XX\Documents\RFC\test2\node_modules\node-rfc\bu
ild\sapnwrfc.vcxproj]
C:\Users\XX\Documents\RFC\test2\node_modules\node-rfc\node_modules\node-addon-api\napi-inl.h(1581,24): error C386
1: 'napi_detach_arraybuffer': identifier not found [C:\Users\XX\Documents\RFC\test2\node_modules\node-rfc\build\s
apnwrfc.vcxproj]
  nwrfcsdk.cc
C:\Users\XX\Documents\RFC\test2\node_modules\node-rfc\node_modules\node-addon-api\napi-inl.h(1575,24): error C386
1: 'napi_is_detached_arraybuffer': identifier not found [C:\Users\XX\Documents\RFC\test2\node_modules\node-rfc\bu
ild\sapnwrfc.vcxproj]
C:\Users\XX\Documents\RFC\test2\node_modules\node-rfc\node_modules\node-addon-api\napi-inl.h(1581,24): error C386
1: 'napi_detach_arraybuffer': identifier not found [C:\Users\XX\Documents\RFC\test2\node_modules\node-rfc\build\s
apnwrfc.vcxproj]
  Pool.cc
C:\Users\XX\Documents\RFC\test2\node_modules\node-rfc\node_modules\node-addon-api\napi-inl.h(1575,24): error C386
1: 'napi_is_detached_arraybuffer': identifier not found [C:\Users\XX\Documents\RFC\test2\node_modules\node-rfc\bu
ild\sapnwrfc.vcxproj]
C:\Users\XX\Documents\RFC\test2\node_modules\node-rfc\node_modules\node-addon-api\napi-inl.h(1581,24): error C386
1: 'napi_detach_arraybuffer': identifier not found [C:\Users\XX\Documents\RFC\test2\node_modules\node-rfc\build\s
apnwrfc.vcxproj]
  Throughput.cc
C:\Users\XX\Documents\RFC\test2\node_modules\node-rfc\node_modules\node-addon-api\napi-inl.h(1575,24): error C386
1: 'napi_is_detached_arraybuffer': identifier not found [C:\Users\XX\Documents\RFC\test2\node_modules\node-rfc\bu
ild\sapnwrfc.vcxproj]
C:\Users\XX\Documents\RFC\test2\node_modules\node-rfc\node_modules\node-addon-api\napi-inl.h(1581,24): error C386
1: 'napi_detach_arraybuffer': identifier not found [C:\Users\XX\Documents\RFC\test2\node_modules\node-rfc\build\s
apnwrfc.vcxproj]
  Server.cc
C:\Users\XX\Documents\RFC\test2\node_modules\node-rfc\node_modules\node-addon-api\napi-inl.h(1575,24): error C386
1: 'napi_is_detached_arraybuffer': identifier not found [C:\Users\XX\Documents\RFC\test2\node_modules\node-rfc\bu
ild\sapnwrfc.vcxproj]
C:\Users\XX\Documents\RFC\test2\node_modules\node-rfc\node_modules\node-addon-api\napi-inl.h(1581,24): error C386
1: 'napi_detach_arraybuffer': identifier not found [C:\Users\XX\Documents\RFC\test2\node_modules\node-rfc\build\s
apnwrfc.vcxproj]
  addon.cc
C:\Users\XX\Documents\RFC\test2\node_modules\node-rfc\node_modules\node-addon-api\napi-inl.h(1575,24): error C386
1: 'napi_is_detached_arraybuffer': identifier not found [C:\Users\XX\Documents\RFC\test2\node_modules\node-rfc\bu
ild\sapnwrfc.vcxproj]
C:\Users\XX\Documents\RFC\test2\node_modules\node-rfc\node_modules\node-addon-api\napi-inl.h(1581,24): error C386
1: 'napi_detach_arraybuffer': identifier not found [C:\Users\XX\Documents\RFC\test2\node_modules\node-rfc\build\s
apnwrfc.vcxproj]
ERR! OMG Process terminated: 1
npm WARN test2@1.0.0 No description
npm WARN test2@1.0.0 No repository field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-rfc@2.3.1 install: `prebuild-install --tag-prefix -r napi || cmake-js rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-rfc@2.3.1 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\XX\AppData\Roaming\npm-cache\_logs\2020-12-22T05_26_53_716Z-debug.log

Please let me know if you can provide any input on this.

Thanks

bsrdjan commented 3 years ago

It looks like the same issue as the initial one. Which nodejs version is used for the installation? The installation using node 12.18.4 and other N-API 6 releases will be fixed in next node-rfc release. For now the above described workaround can be used.

h2plucifer commented 3 years ago

Node version used : v12.18.4 Node arch : ia32

Though error message seems some how different : napi_detach_arraybuffer': identifier not found [C:\Users\XX\Documents\RFC\test2\node_modules\node-rfc\build\s apnwrfc.vcxproj]

Until few days ago I was successfully able to install the node-rfc module with this node.js instance but now its throwing this error message.

Thanks,

h2plucifer commented 3 years ago

Hi @bsrdjan ,

can you let me know when we could expect the next release of node-rfc with the mentioned fix . Is there any timeline that you could provide

Thanks,

bsrdjan commented 3 years ago

The next node-rfc release should follow, in a week or two, the next SAP NWRFC SDK release (PL8).

Because of the PL7 memory corruption issue I hope we will not wait long for PL8.

h2plucifer commented 3 years ago

Thanks for the update

h2plucifer commented 3 years ago

Hi @bsrdjan ,

Would like to know if there is any specific date for the next release of node-rfc.

Thanks

bsrdjan commented 3 years ago

Hi @h2plucifer ,

The node-rfc 2.4.0 is just published. There is no public release plan for PL8 but you can check the release dynamic of past years. It should be more or less the same also this year.

You can create SAP customer incident and request the PL8 pre-release for you.

Regards, Srdjan

h2plucifer commented 3 years ago

Thanks @bsrdjan ,
Will try the latest node-rfc release & do the needful as suggested.

Regards Hari Pradhan

h2plucifer commented 3 years ago

HI @bsrdjan ,

I need to check if the rfmcall package has been permanently removed from registry or if there would be any updated publication.

(rfmcall unpublished url : https://developer.aliyun.com/mirror/npm/package/rfmcall)

Need to check about rfmcall as our SDK implementation utilizes its functionality.

Thanks, Hari Pradhan

bsrdjan commented 3 years ago

Could you please move the question to https://github.com/SAP/fundamental-tools repository, where rfmcall belongs?

Update follows soon.

h2plucifer commented 3 years ago

Ok sure, Thanks

bsrdjan commented 3 years ago

Apparently fixed, please re-open if needed.