This may be working as intended and I am just not fully understanding how disconnects work, but I have a chat client that I set the heartbeat to 30seconds (i know that's low).
Using chrome's debugger throttling I would set throttling profile to offline then immediately watch the time.
1st pass
- Javascript Client disconnect callback fired after ~300s (the default)
- Server side presence "timeout" received ~300s later
2nd pass
- Client disconnect callback fired after exactly 30s (the heartbeat i set)
- Server side presence "timeout" received ~31s
3rd pass
- Client disconnect callback fired after ~270 seconds (30seconds less than the default)
- Server side presence "timeout" received ~272 seconds
4th pass
- Client disconnect callback fired after ~249 seconds
- Server side presence "timeout" received ~248 seconds
The javascript client is firing the event at pretty much the same time as the "timeout" presence is sent out. However, I cannot figure out the rhyme or reason why the time it takes them to fire vary so much.
Is it possible to have the system ALWAYS fire the disconnect callback and "timeout" presence after 30sec of connectivity loss?
EDIT: Using the latest SDK 3.14.4
Client 1:
var client = PUBNUB.init({
subscribe_key: 'sub-key',
restore: false,
ssl: true,
uuid: 'client1',
heartbeat: 30
});
client.subscribe({
channel: 'mychannel2',
connect: function () {
console.log('Connected');
},
disconnect: function () {
console.log('Disconnected');
},
reconnect: function () {
console.log('Reconnected');
},
error: function () {
console.log('Error');
},
message: function (message) {
console.log('Message: ' + JSON.stringify(message));
}
});
Client 2:
var client = PUBNUB.init({
subscribe_key: 'sub-key',
restore: true,
ssl: true,
uuid: 'client2'
});
client.channel_group_add_channel({
channel: 'mychannel2',
channel_group: 'mygroup'});
client.subscribe({
channel_group: 'mygroup',
connect: function () {
console.log('Connected');
},
disconnect: function () {
console.log('Disconnected');
},
reconnect: function () {
console.log('Reconnected');
},
error: function () {
console.log('Error');
},
message: function (message) {
console.log('Message: ' + JSON.stringify(message));
},
presence: function (message) {
console.log('Presence: ' + JSON.stringify(message));
}
});