diff --git a/exec/broker.js b/exec/broker.js
index c0e34c950f6bc2f064901a2ef41c9f4a171be754..6d8146f586a07a9bfbf1fa7e87a8d15d65213315 100644
--- a/exec/broker.js
+++ b/exec/broker.js
@@ -2227,7 +2227,7 @@ MQTT.Packet.SUBSCRIBE.prototype.recv = function(conn) {
 		var tfilter = conn.getUTF8String();
 		var sopts = new MQTT.Connection.SubscriptionOptions(conn.getByte());
 		this.payload.push({topic_filter: tfilter, subscription_options: sopts});
-	} while ((start_len - conn.rx_buf.length) > this.pkt_length);
+	} while ((start_len - conn.rx_buf.length) < this.pkt_length);
 };
 
 // MQTT.Packet.SUBACK class
@@ -2280,7 +2280,7 @@ MQTT.Packet.UNSUBSCRIBE.prototype.recv = function(conn) {
 
 	do {
 		this.payload.push(conn.getUTF8String());
-	} while ((start_len - conn.rx_buf.length) > this.pkt_length);
+	} while ((start_len - conn.rx_buf.length) < this.pkt_length);
 };
 
 // MQTT.Packet.UNSUBACK class