Skip to Content

XS Advanced - Node.js Module - HDB Connection Error "ConnectionManager"

Hi,

after we installed Hana 2.0 we get this error.

In the past the project was working fine and we didn't change anything since then.

Error: Could not connect to any host: [ undefined:NaN - connect ECONNREFUSED 127.0.0.1 ]
   at couldNotOpenConnectionError (/HANA/usr_sap/hana1/xs/ea_data/hana1/executionroot/1277e046-fc5f-4835-b1d0-9927e6ed978a/app/node_modules/hdb/lib/protocol/ConnectionManager.js:130:13)
   at ConnectionManager._openConnectionToHost (/HANA/usr_sap/hana1/xs/ea_data/hana1/executionroot/1277e046-fc5f-4835-b1d0-9927e6ed978a/app/node_modules/hdb/lib/protocol/ConnectionManager.js:43:15)
   at /HANA/usr_sap/hana1/xs/ea_data/hana1/executionroot/1277e046-fc5f-4835-b1d0-9927e6ed978a/app/node_modules/hdb/lib/protocol/ConnectionManager.js:56:10
   at Socket.onerror (/HANA/usr_sap/hana1/xs/ea_data/hana1/executionroot/1277e046-fc5f-4835-b1d0-9927e6ed978a/app/node_modules/hdb/lib/protocol/Connection.js:168:5)
   at Socket.g (events.js:291:16)
   at emitOne (events.js:96:13)
   at Socket.emit (events.js:188:7)
   at emitErrorNT (net.js:1276:8)
   at _combinedTickCallback (internal/process/next_tick.js:74:11)
   at process._tickCallback (internal/process/next_tick.js:98:9)

Any ideas what the reason could be?

Add comment
10|10000 characters needed characters exceeded

  • I found this link, which describes exactly our problem:

    XS Advanced - Node.js Module - HDB Connection Error

    We are using the sap-hdbext on the same way as R.M. has described in his post.

    	app.use(
    		passport.authenticate("JWT", {
    			session: false
    		}),
    		xsHDBConn.middleware());
    
    ========================================
    	//Simple Database Select - In-line Callbacks
    	app.route("/simptab")
    		.get(function(req, res) {
    			var client = req.db;
    			client.prepare(
  • Hi All

    We are having the same exact problem in Cloud Application Program in Cloud Foundry with Hana 2.0. The app was working fine with CDS oData calls and it stopped working this week with this same exact error. Any help is much appreciated. We already implemented the above suggestions in our Server.js in node service.

    Thanks

    Sasi

  • Follow
  • Get RSS Feed

2 Answers

  • Best Answer
    avatar image
    Former Member
    Feb 03, 2017 at 09:46 AM

    Hi Dirk,

    I assume you are using the standard npm-packages provided by SAP and you want to use a SAML-Authentification. SAP updated some of their node.js-modules for HANA2. You need for your package.json the following dependencies

    "dependencies": {<br>    "express": "~4.14",
        "passport": "~0.3.2",
        "sap-hdbext": "4.2.0",
        "sap-xssec": "0.9.1",
        "sap-xsenv": "1.2.4",
        "sap-xsjs": "latest"
    }

    To achieve your goal, you must authentificate like this within your server.js (or similar):

    "use strict";
    var port = process.env.PORT || 3000,
    	server = require("http").createServer(),
    	express = require("express"),
    	app = express(),
    	xssec = require("sap-xssec"),
    	xsjs = require("sap-xsjs"),
    	xsenv = require("sap-xsenv"),
    	passport = require("passport"),
    	xsHDBConn = require("sap-hdbext");
    
    /**
     * JSON WEB TOKEN AUTHENTICATION
     */
    //configure HANA 
    var options = Object.assign({redirectUrl: "/index.xsjs"}, 
    	xsenv.getServices({
    		uaa: { tag: "xsuaa" },
    		hana: { tag: "hana" }
    	})
    );
    
    // Authentication Module Configuration
    passport.use("JWT", new xssec.JWTStrategy(options.uaa));
    
    // Use for every Request this Authentication mode
    app.use(
    	passport.authenticate("JWT", { session: false }),
    	xsHDBConn.middleware(options.hana)
    );
    
    // start server
    var xsjsApp = xsjs(options);
    app.use(xsjsApp);
    app.listen(port); 
    

    You are now able to use SAML-Tokens and oData as well.

    Add comment
    10|10000 characters needed characters exceeded

  • Feb 03, 2017 at 09:53 AM

    Hi Sören,

    thanks for this really smart solution!!!

    I'm sure it will solve our problem. ;)

    BR,

    DR

    Add comment
    10|10000 characters needed characters exceeded