I am using the following code for pubnub connection.
pubnub = new PubNub({
subscribeKey: "demo",
publishKey: "demo",
keepAlive: true,
})
pubnub.addListener({
message: function(message){
console.log(message.channel+' '+message.publisher+' '+message.message.name+' '+time)
},
status: function(s) {
console.log(s.category+" "+s.operation+" "+s.affectedChannels +" "+s.subscribedChannels +" "+s.affectedChannelGroups+" "+time+" "+s.message)
}
});
pubnub.history(
{
//child0, new
channel: 'child3',
reverse: true,
count: 10
},
function (status, response) {
// console.log(response);
console.log(response.messages);
}
);
pubnub.subscribe({
channels: ['child3'],
// resubscribe and reconnect
restore : true,
//callback: function(m){console.log(m)} ,
});
I had two nodejs scripts, one for publish and another for subscribe a message in pubnub.
When the Subscriber is online, it is able to receive messages from the Publisher but when the Subscriber goes offline, it is unable to receive the appropriate message from the Publisher due to a faulty network connection, occurring due to an erroneous Subscribe Script.
Please resolve this issue.