PostgreSQL 9.6.2 I send requests from the node.js + sequelize application
The sequelize documentation has examples of querying, in this case, findAll
Trying an example
console.log('user id: ', req.decoded); db.orders.findAll({where: {userId: req.decoded.id}}) .then(function (orders) { console.log('orders from db: ', orders); }) .catch(function (err) { console.log('orders request error from db: ', err); }); console.log('end of function'); Console log
user id: { id: 2 } end of function orders request error from db: { SequelizeConnectionError: read ECONNRESET at D:\NodeJSProjects\ParkingHouse\node_modules\sequelize\lib\dialects\postgres\connection-manager.js:110:20 at Connection.<anonymous> (D:\NodeJSProjects\ParkingHouse\node_modules\pg\lib\client.js:186:5) at emitOne (events.js:96:13) at Connection.emit (events.js:188:7) at Socket.<anonymous> (D:\NodeJSProjects\ParkingHouse\node_modules\pg\lib\connection.js:86:10) at emitOne (events.js:96:13) at Socket.emit (events.js:188:7) at emitErrorNT (net.js:1278:8) at _combinedTickCallback (internal/process/next_tick.js:74:11) at process._tickCallback (internal/process/next_tick.js:98:9) name: 'SequelizeConnectionError', message: 'read ECONNRESET', parent: { Error: read ECONNRESET at exports._errnoException (util.js:1022:11) at TCP.onread (net.js:569:26) code: 'ECONNRESET', errno: 'ECONNRESET', syscall: 'read' }, original: { Error: read ECONNRESET at exports._errnoException (util.js:1022:11) at TCP.onread (net.js:569:26) code: 'ECONNRESET', errno: 'ECONNRESET', syscall: 'read' } } after some time, the request is repeated and already then I receive the data and the database.
- Why does the server stop the connection?
- Should the request be wrapped in a promise to wait for an answer?