Skip to content

Commit

Permalink
[MQTT-3.1.0-2] Only one CONNECT for whole session
Browse files Browse the repository at this point in the history
A Client can only send the CONNECT Packet once over a Network Connection. The Server MUST process a second CONNECT Packet sent from a Client as a protocol violation and disconnect the Client
  • Loading branch information
gnought committed Jul 15, 2019
1 parent ef99045 commit 06fc839
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/handlers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ var handlePubrec = require('./pubrec')
var handlePing = require('./ping')

function handle (client, packet, done) {
if (packet.cmd !== 'connect' && !client.connected) {
if (
// [MQTT-3.1.0-1]
(packet.cmd !== 'connect' && !client.connected) ||
// [MQTT-3.1.0-2]
(packet.cmd === 'connect' && client.connected)
) {
client.conn.destroy()
return
}
Expand Down

0 comments on commit 06fc839

Please sign in to comment.