node-postgres:无法从postgres CLI发出NOTIFY作业

我有一些代码可以在PHP中正常工作。 从postgres CLI我发出一个

NOTIFY job; 

Postgres(我可以在PHP客户端中看到它)正确提出通知,但无法在节点中读取它。

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'); }); 

我宁愿保持简单。 是在这样的postgres做程序的唯一方法?

好的,问题是在conString参数。

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

检查是否使用正确的数据库来获取通知消息很重要。