使用SAP Cloud SDK for JS从本地连接OnPremise目标失败
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.

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 sshprocess:- 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.
- Windows: Run
- Test the tunnel manually with curl:
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.curl -x http://localhost:5001 <your-on-premise-target-url>
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"andproxyType: "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

