我有一些在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');
});

我宁愿保持简单。是唯一的方法
this

最佳答案

好的,问题出在constring参数中。

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

重要的是要检查您是否使用了正确的数据库来访问通知消息。

07-28 01:40
查看更多