cap-js / cds-dbs

Monorepo for SQL Database Services for CAP
https://cap.cloud.sap/docs/
Apache License 2.0
36 stars 11 forks source link

postgres in hybrid profile #476

Open lucasborin opened 8 months ago

lucasborin commented 8 months ago

Description of erroneous behaviour

The statement cds watch --profile hybrid binds the Postgres instance, but the CAP read fails due to resource timeout.

CAP database call:

const entries = await cds.db.run(`SELECT * FROM ... LIMIT 10`)

Console (sensitive data hidden):

[odata] - POST /odata/v4/...
[cds] - TimeoutError: ResourceRequest timed out
    at ResourceRequest._fireTimeout (/home/.../node_modules/generic-pool/lib/ResourceRequest.js:62:17)
    at Timeout.bound (/home/.../node_modules/generic-pool/lib/ResourceRequest.js:8:15)
    at listOnTimeout (node:internal/timers:569:17)
    at process.processTimers (node:internal/timers:512:7)

Project .cdsrc.json:

{
    "requires": {
        "destinations": true,
        "db": {
            "kind": "postgres",
            "dialect": "postgres",
            "impl": "@cap-js/postgres"
        },
        "auth": {
            "kind": "xsuaa",
            "restrict_all_services": false
        }
}

Project .cdsrc-private.json (sensitive data hidden):

{
  "requires": {
    "[hybrid]": {
      "destinations": {
        "binding": {
          "type": "cf",
          "apiEndpoint": "...",
          "org": "...",
          "space": "...",
          "instance": "...",
          "key": "...",
          "resolved": false
        },
        "kind": "destinations",
        "vcap": {
          "name": "destinations"
        }
      },
      "db": {
        "binding": {
          "type": "cf",
          "apiEndpoint": "...",
          "org": "...",
          "space": "...",
          "instance": "...",
          "key": "...",
          "resolved": false
        },
        "kind": "postgres",
        "vcap": {
          "name": "db"
        }
      },
      "auth": {
        "binding": {
          "type": "cf",
          "apiEndpoint": "...",
          "org": "...",
          "space": "...",
          "instance": "...",
          "key": "...",
          "resolved": false
        },
        "kind": "xsuaa",
        "vcap": {
          "name": "auth"
        }
      }
    }
  }
}

Details about your project

Interal Ask i840577
Node.js v18.19.0
@sap/cds 7.3.1
@sap/cds-compiler 4.3.2
@sap/cds-dk 7.3.2
@sap/cds-dk (global) 7.6.1
@sap/eslint-plugin-cds 2.6.3
@sap/cds-mtxs 1.12.1
@cap-js/cds-types 0.2.0
vobu commented 8 months ago

hm, I did the same thing, but on Azure: https://github.com/Azure-Samples/app-service-javascript-sap-cap-quickstart/blob/293b5a4d78c3ccd2ca38440b0b01a19c2ae6f517/src/.cdsrc.json#L26 that worked ootb. → assumption: this might be an issue with CF/destination?

patricebender commented 6 months ago

@lucasborin have you been able to solve this problem on your end?

lucasborin commented 6 months ago

@lucasborin have you been able to solve this problem on your end?

I'm using SAP HANA now, and I was not able to use the postgres in hybrid mode.

arunkrishnamoorthy commented 4 months ago

[odata] - > READ Activities { '$count': 'true', '$filter': '(IsActiveEntity eq false or SiblingEntity/IsActiveEntity eq null)', '$select': 'HasActiveEntity,IsActiveEntity,accountManagerId,accountManagerName,activityAdministrator,activityDesc,activityId,activityOrg,contract,goLiveDate,modifiedAt,modifiedBy,projectManagerId,projectManagerName', '$skip': '0', '$top': '30' } [cds] - TimeoutError: ResourceRequest timed out at ResourceRequest._fireTimeout (/home/user/projects/timesheet/packages/server/node_modules/generic-pool/lib/ResourceRequest.js:62:17) at Timeout.bound (/home/user/projects/timesheet/packages/server/node_modules/generic-pool/lib/ResourceRequest.js:8:15) at listOnTimeout (node:internal/timers:573:17) at process.processTimers (node:internal/timers:514:7) Active connections:0 { id: '1017596', level: 'ERROR', timestamp: 1720285318950 }

I am facing the same issue. Is there a solution or workaround available for this to test the postgre db in hybrid mode

BobdenOs commented 2 weeks ago

@arunkrishnamoorthy it is not possible to give support with the ResourceRequest timed out error. If you are still facing this issue please catch the error thrown here. Most likely the error message will already give you an indication of what is going wrong. Most likely the connection is being rejected as your host is blocked. It is standard practice for internal services to only allow known internal host to connect to the server.