You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用SAP Cloud SDK for JS从本地连接OnPremise目标失败

ECONNREFUSED Error When Connecting to On-Premise System via SAP Cloud SDK for JavaScript (Local Environment)

Problem Description

We're encountering an ECONNREFUSED error when calling executeHttpRequest while using SAP Cloud SDK for JavaScript to connect to an On-Premise target system from a local environment.

ECONNREFUSED Error Screenshot

Dependencies in package.json:

"@sap-cloud-sdk/connectivity": "2.1.0",
"@sap-cloud-sdk/http-client": "2.1.0",
"@sap-cloud-sdk/test-util": "2.0.0"

Completed Configuration Steps:

  • Followed all official guidelines for connecting to On-Premise systems via the SDK
  • Established SSH tunnel using: cf ssh my-app -L localhost:5001:connectivityproxy.internal.cf.eu10.hana.ondemand.com:20003
  • Bound the Connectivity service instance to the CF application
  • Confirmed Cloud Connector is running and connected

Troubleshooting & Solutions

1. Verify SSH Tunnel Status

  • Check if the local port 5001 is occupied by the cf ssh process:
    • Windows: Run netstat -ano | findstr :5001
    • Mac/Linux: Run lsof -i :5001
      If no results are returned, the tunnel wasn't established successfully. Re-run the SSH command and ensure no errors occur during execution.
  • Test the tunnel manually with curl:
    curl -x http://localhost:5001 <your-on-premise-target-url>
    
    If this also fails, the tunnel itself has issues. Check the Connectivity service permissions for your CF app, or restart the CF CLI and re-establish the tunnel.

2. Explicitly Configure Proxy in SDK

Ensure the SDK uses the local tunnel port to route traffic. Add explicit proxy configuration to your destination setup:

import { executeHttpRequest } from '@sap-cloud-sdk/http-client';
import { getDestination } from '@sap-cloud-sdk/connectivity';

const destination = await getDestination('your-target-name');
// Override proxy to point to local tunnel
(destination as any).proxyConfiguration = {
  host: 'localhost',
  port: 5001
};

const response = await executeHttpRequest(destination, { method: 'GET', url: '/your-api-path' });

Note: If using test-util to load destinations, ensure no existing config overrides this proxy setting.

3. Validate Cloud Connector Setup

  • Confirm the Cloud Connector shows a connected status for your On-Premise system mapping.
  • Verify the access control list includes your CF space GUID (retrieve via cf space <your-space-name> --guid).
  • Ensure the target system's hostname and port in Cloud Connector exactly match the configuration in your SDK destination (check for case sensitivity and port numbers).

4. Align SDK Dependency Versions

The @sap-cloud-sdk/test-util version (2.0.0) is mismatched with other core SDK libraries (2.1.0), which may cause configuration loading issues. Update all SDK dependencies to the same version:

"@sap-cloud-sdk/connectivity": "2.1.0",
"@sap-cloud-sdk/http-client": "2.1.0",
"@sap-cloud-sdk/test-util": "2.1.0"

Run npm install after updating, then re-test the connection.

5. Check Destination Configuration Details

  • Ensure the destination has type: "HTTP" and proxyType: "OnPremise" set correctly.
  • If using OAuth authentication, verify client ID, secret, and token endpoint are valid and have sufficient permissions to access the target system.
  • Print destination details to validate parameters:
const destination = await getDestination('your-target-name');
console.log('Destination Details:', JSON.stringify(destination, null, 2));

6. Rule Out Local Firewall/Security Software

Temporarily disable local firewalls or security tools, or add a rule allowing CF CLI to communicate on port 5001. These tools may block traffic through the local tunnel.


内容的提问来源于stack exchange,提问作者Ronit Nath

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.08 04:55:13