问题
Pg-promise is Not returning anything for 60s and gets timed out while running server setup with express-generator. There are no error messages.
All the routes without db.any
or similar query, works fine. The routes with db.*
times out.
But, the same connection/route/query works perfectly with a simple express app.
I am running this from AWS EC2.
Here is the test sample express that worked fine. Same route in routes/index.js does not work - gets timed out.
const express = require('express');
const app = express();
const options = {
query: function (e) {
console.log(e.query);
},
};
const pgp = require('pg-promise')(options);
const connection = 'postgres://user:pwd@endpoint:5432/db';
const db = pgp(connection);
app.get('/test', (req, res) => {
db.any('select id from users')
.then(data => {
res.json({
data,
});
}).catch(err => {
res.json({
err,
});
});
});
app.listen(4000, () => {
console.log('db app listening on port 4000!');
});
module.exports = app;
Not sure what I am missing? What could be the issue!
来源:https://stackoverflow.com/questions/65152018/pg-promise-timeout-while-using-express-generator-format-but-works-fine-with-bas