mqttjs / mqtt-connection

Barebone Connection object for MQTT in node.js
Other
114 stars 25 forks source link

mqtt messages are received fragmented on client #9

Closed swapnil-hike closed 7 years ago

swapnil-hike commented 7 years ago

Single mqtt message are received as multiple TCP PDU's on client.

screen shot 2017-04-16 at 1 26 23 am
swapnil-hike commented 7 years ago

Script (copied from example ) and wireshark attached frag.pcap.zip


var net = require('net') var mqttCon = require('mqtt-connection') var server = new net.Server()

server.on('connection', function (stream) { var client = mqttCon(stream)

// client connected client.on('connect', function (packet) { // acknowledge the connect packet client.connack({ returnCode: 0 }); })

// client published client.on('publish', function (packet) { // send a puback with messageId (for QoS > 0) client.puback({ messageId: packet.messageId }) })

// client pinged client.on('pingreq', function () { // send a pingresp client.pingresp() });

// client subscribed client.on('subscribe', function (packet) { // send a suback with messageId and granted QoS level client.suback({ granted: [packet.qos], messageId: packet.messageId }) })

// timeout idle streams after 5 minutes stream.setTimeout(1000 60 5)

// connection error handling client.on('close', function () { client.destroy() }) client.on('error', function () { client.destroy() }) client.on('disconnect', function () { client.destroy() })

// stream timeout stream.on('timeout', function () { client.destroy(); }) })

// listen on port 1883 server.listen(1883)

mcollina commented 7 years ago

which OS are you using? can you verify if you get the same behavior just using https://github.com/mqttjs/mqtt-packet?

swapnil-hike commented 7 years ago

@mcollina Thanks a lot .. Have shelved the project for a while .. Will test it when ever possible and let you know.