I'm using pubnub in a node.js project. I can initialize pubnub and publish a message like:
Node.js
var PUBNUB = require('pubnub');
var pubnub = PUBNUB.init({
publish_key : 'demo',
subscribe_key : 'demo'
});
var CHANNEL = 'test1234';
pubnub.subscribe({
channel: CHANNEL,
message: function (message) {
console.log('Received message:', message);
// unsubscribe again
pubnub.unsubscribe({channel: CHANNEL});
// PROBLEM: The node.js process does not exit because pubnub is still
// active. How to close the pubnub connection so it's completely
// gone from memory?
},
connect: function () {
// send a test message
pubnub.publish({channel: CHANNEL, message: 'hello world!'});
}
});
But how can I close this pubnub instance? So that it's gone from memory and event loop and does not keep the node.js process running.
I can't find anything in the API documentation, and tried pubnub.close(), pubnub.destroy(), and pubnub.disconnect() without success.
This issue is resolved in a newer version of pubnub (current is v3.7.8).