{"action":"created","issue":{"url":"https://api.github.com/repos/brianc/node-postgres/issues/967","repository_url":"https://api.github.com/repos/brianc/node-postgres","labels_url":"https://api.github.com/repos/brianc/node-postgres/issues/967/labels{/name}","comments_url":"https://api.github.com/repos/brianc/node-postgres/issues/967/comments","events_url":"https://api.github.com/repos/brianc/node-postgres/issues/967/events","html_url":"https://github.com/brianc/node-postgres/issues/967","id":140652838,"number":967,"title":"LISTEN notifications stop after a while","user":{"login":"super-cache-money","id":1463145,"avatar_url":"https://avatars1.githubusercontent.com/u/1463145?v=3","gravatar_id":"","url":"https://api.github.com/users/super-cache-money","html_url":"https://github.com/super-cache-money","followers_url":"https://api.github.com/users/super-cache-money/followers","following_url":"https://api.github.com/users/super-cache-money/following{/other_user}","gists_url":"https://api.github.com/users/super-cache-money/gists{/gist_id}","starred_url":"https://api.github.com/users/super-cache-money/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/super-cache-money/subscriptions","organizations_url":"https://api.github.com/users/super-cache-money/orgs","repos_url":"https://api.github.com/users/super-cache-money/repos","events_url":"https://api.github.com/users/super-cache-money/events{/privacy}","received_events_url":"https://api.github.com/users/super-cache-money/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":18,"created_at":"2016-03-14T11:53:43Z","updated_at":"2017-05-26T14:03:45Z","closed_at":null,"body":"I'm using `LISTEN` to be notified of changes. It used to work perfectly when I was listening to a DB on `localhost`. However, now that I've moved the DB over to another VM, I'm encountering some problems where my client loses \"sync\" with the DB and stops receiving notifications after some time (in order of minutes/hours). \n\nI'm not using the connection pool, here's how I connect and listen to updates: \n\n```\nvar client = new pg.Client(pgConString);\nclient.connect(function(err, client) {\n    if(err) {\n      throw err;\n    }\n    client.on('notification', function(msg) {\n        console.log(msg.payload);\n    });\n    client.on('error', function(error) {\n      console.error('This never even runs:', error);\n    });\n    var query = client.query(\"LISTEN watchers\");\n});\n```\n\nIs it possible keep this listener working indefinitely? Am I doing something silly? What is supposed to happen after a momentary network failure? Do I have to resign to polling the DB and diffing changes? \n"},"comment":{"url":"https://api.github.com/repos/brianc/node-postgres/issues/comments/304290472","html_url":"https://github.com/brianc/node-postgres/issues/967#issuecomment-304290472","issue_url":"https://api.github.com/repos/brianc/node-postgres/issues/967","id":304290472,"user":{"login":"brianc","id":50081,"avatar_url":"https://avatars3.githubusercontent.com/u/50081?v=3","gravatar_id":"","url":"https://api.github.com/users/brianc","html_url":"https://github.com/brianc","followers_url":"https://api.github.com/users/brianc/followers","following_url":"https://api.github.com/users/brianc/following{/other_user}","gists_url":"https://api.github.com/users/brianc/gists{/gist_id}","starred_url":"https://api.github.com/users/brianc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brianc/subscriptions","organizations_url":"https://api.github.com/users/brianc/orgs","repos_url":"https://api.github.com/users/brianc/repos","events_url":"https://api.github.com/users/brianc/events{/privacy}","received_events_url":"https://api.github.com/users/brianc/received_events","type":"User","site_admin":false},"created_at":"2017-05-26T14:03:45Z","updated_at":"2017-05-26T14:03:45Z","body":"nice @doesdev - I've got some stuff on the 7.0 milestone to handle network partitions better & do research into why sometimes connections drop but don't report.  I have a hunch it has to do w/ not setting heartbeats on the tcp connection to the backend, but I haven't dug in yet.  I guess the somehwat good news is it's on my radar. :smile: "}}
{"actor":{"display_login":"brianc"}}