Closed fox-alvarez closed 11 years ago
good day.
The solution was next, brianc wrote me the following message:
You're using the connection pool with pg.connect
When you are finished with the client do not call end
on the client. Return the client to the pool. Currently you're starving out your pool by checking out clients, ending them manually, and never returning them to the pool.
Please see this for more information:
https://github.com/brianc/node-postgres/wiki/pg
the change was as follows hise:
pg.connect(conString, function(err,client) {
var soc=Math.floor((Math.random()*1000)+1);
var StringConsulta="select conectados_ins(1,'"+soc+"',true,2)";
var consultaSQL=client.query(StringConsulta);
consultaSQL.on('row', function(row) {
client.end.bind(client);
console.log("User successfully added");
});
});
to
pg.connect(conString, function(err,client,done) {
var soc=Math.floor((Math.random()*1000)+1);
var StringConsulta="select conectados_ins(1,'"+soc+"',true,2)";
var consultaSQL=client.query(StringConsulta);
consultaSQL.on('row', function(row) {
console.log("User successfully added");
done();
});
});
works great regards
Hello
after 10 connections to the database the "pg" dies and the node is still alive but can not interact with the DDBB.
The following is the code of my servidor.js
node version:
output after installation of pg:
I'm sure it's on the 10th connexion that "pg" dies, because the console does not return to apareceer the message "User successfully added"
Regards