Skip to content

Commit

Permalink
fix: do not shift pings on 'publish' packets
Browse files Browse the repository at this point in the history
Fixes #1863 #1861
  • Loading branch information
robertsLando committed May 13, 2024
1 parent 6a03d29 commit e73b670
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/lib/handlers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const handle: PacketHandler = (client, packet, done) => {
client.pingResp = Date.now()

// do not shift on pingresp otherwise we would skip the pingreq sending
if (packet.cmd !== 'pingresp') {
if (!['pingresp', 'publish'].includes(packet.cmd)) {
client['_shiftPingInterval']()
}

Expand Down
8 changes: 8 additions & 0 deletions test/abstract_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2009,6 +2009,14 @@ export default function abstractTest(server, config, ports) {
const spy = sinon.spy()
client['_checkPing'] = spy

server.once('client', (serverClient) => {
// send fake packet to client
serverClient.publish({
topic: 'foo',
payload: 'bar',
})
})

client.once('connect', () => {
client.publish('foo', 'bar')
clock.tick(intervalMs)
Expand Down

0 comments on commit e73b670

Please sign in to comment.