Scale up as you grow — whether you're running one virtual machine or ten thousand.

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.

By terrarum
I have a managed Postgres database and an App that currently just contains a Function written in Node.
I have added my App and my local IP as trusted sources to my database.
I can query the database from my computer, but the exact same code times out when connecting to the database when running in both the Sandbox and Production Function environments.
This works:
const pool = new Pool({
connectionTimeoutMillis: parseInt(process.env.PGCONTIMEOUT),
user: process.env.PGUSER,
host: process.env.PGHOST,
database: process.env.PGDATABASE,
password: process.env.PGPASSWORD,
port: parseInt(process.env.PGPORT),
ssl: {
ca: process.env.CA_CERT
},
});
let failure = null;
const response = await pool.query('SELECT test_column FROM mrspeaker.mrspeaker.test')
.catch(reason => failure = reason);
await pool.end();
const actual = failure === null ? response.rows[0].test_column : failure.toString();
expect(actual).toEqual(595);
The exact same code (replacing the assertion with return actual;) running in the function sandbox just returns Error: Connection terminated due to connection timeout.
If I remove all trusted sources from the database I get the same result.
My project.yml:
targetNamespace: ''
parameters: {}
packages:
- name: mrspeaker
actions:
- name: main
runtime: 'nodejs:default'
- name: hello
runtime: 'nodejs:default'
environment:
BOT_TOKEN: ${BOT_TOKEN}
PGHOST: ${PGHOST}
PGPORT: ${PGPORT}
PGUSER: ${PGUSER}
PGPASSWORD: ${PGPASSWORD}
PGDATABASE: ${PGDATABASE}
PGCONTIMEOUT: ${PGCONTIMEOUT}
CA_CERT: ${CA_CERT}
My deploy command for the sandbox: doctl sandbox deploy . --env .env
My .env file with values removed:
BOT_TOKEN=
PGHOST=
PGPORT=
PGCONTIMEOUT=
PGDATABASE=
PGUSER=
PGPASSWORD=
CA_CERT=
Am I totally misunderstanding something or am I just missing a small detail? Any help would be greatly appreciated!
Aakash Singh
Aakash Singh
Frank Tufano
fullammo
4ae272398ee6445a9bf73f4cd632b5
eddie
Taha Aziz Ben Ali
Telmo Valverde
Alexandre Herlinvaux
52d4eff26a544eefb189e2005836b2