node-postgres:不工作从postgres CLI发出NOTIFY作业

Mar*_*ñuk 5 postgresql node.js

我有一些在PHP中运行正常的代码.从postgres CLI我发出一个

NOTIFY job;
Run Code Online (Sandbox Code Playgroud)

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');
});
Run Code Online (Sandbox Code Playgroud)

我宁愿保持简单.就是让像Postgres的一个过程的唯一途径这个

Mar*_*ñuk 3

好的,问题出在 conString 参数上。

var conString = "tcp://user:pass@localhost/db";
Run Code Online (Sandbox Code Playgroud)

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