5

I have some code thats works Ok in PHP. From the postgres CLI I issue a

NOTIFY job;

The notification is correctly raised by Postgres ( I can see it in the PHP client), but can't read it in node.

JS:

var pg = require('pg');
var conString = "your postgres information";
var client = new pg.Client(conString);

client.connect();
client.query('LISTEN job');
client.on('notification', function(msg) {
    console.log('data');
});

I would prefer to keep it simple. Is the only way to make a procedure in postgres like this?

3
  • Ok, the problem was in the conString var conString = "tcp://user:pass@localhost/db"; I was connected to the generic postgres db, and not the correct one. Commented Nov 19, 2012 at 18:40
  • Please post that as an answer and accept it when the timer lets you. I'll upvote if you leave a comment here when you've done so. Thanks for following up. Commented Nov 20, 2012 at 0:10
  • I did it, but forgot to comment here :) thanks! Commented Nov 21, 2012 at 10:51

1 Answer 1

3

Ok, the problem was in the conString parameter.

var conString = "tcp://user:pass@localhost/db";

Is important to check that you are using the correct database to reach the notification messages.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.