Comments (10)
With a minor tweak to EventEmitter settings, this can be avoided. More on this here.
To solve the issue you could add this line to your index file:
process.setMaxListeners(0)
If that doesn't solve the problem, you could also add this line in the connackSent
event handler:
client.conn._maxListeners = 500;
from aedes.
@cordovapolymer You can try bumping the concurrency
param in the Aedes options to a sufficient amount to avoid the warning, but in which ways messages shouldn't be dropped.
from aedes.
can you please a testing script so we can easily reproduce?
from aedes.
@rahulbhanushali tryed process.setMaxListeners(0), seems that the warning was suppressed, but messages are still not delivered.
@GavinDmello tried setting concurrency param to 1000 and 10000, nothing changed.
@mcollina can you please a testing script so we can easily reproduce?
updated to run as node mqtt-test.js
, download a 4MB image for test
// mqtt-test.js
/*jslint node: true, esversion: 6 */
'use strict';
console.log("loading mqtt-test module");
var MqttTest = class MqttTest {
constructor() {
console.log("instanciating mqtt module");
this.mqtt = require('mqtt');
this.client = this.mqtt.connect('mqtt://broker');
var fs = require('fs');
var data = {};
function base64_encode(file) {
// read binary data
var bitmap = fs.readFileSync(file);
// convert binary data to base64 encoded string
return new Buffer(bitmap).toString('base64');
}
var base64str = base64_encode('msg-1-fc-40.jpg');
data.message = base64str;
data.topic = 'message/topic';
var jsonMessage = JSON.stringify(data.message);
if(jsonMessage.length >= 2048){
var messageChunks = this.chunkSubstr(jsonMessage, 2048);
var messageId = Math.random().toString(36).substr(2, 16);
var chunkNumber = 0;
var totalChunks = messageChunks.length;
console.log('totalChunks'+totalChunks);
messageChunks.forEach(function(messageChunk) {
var chunk = {data: {}};
chunk.partial = {};
chunk.partial.number = chunkNumber;
chunk.partial.id = messageId;
chunk.partial.total = totalChunks;
chunk.data = messageChunk;
chunk.topic = jsonMessage.topic;
this.client.publish(data.topic, JSON.stringify(chunk), {'qos': 2});
chunkNumber++;
}, this);
}
else{
this.client.publish(data.topic, jsonMessage, {'qos': 2});
}
this.client.on('connect', function () {
console.log("MQTT connected");
}.bind(this));
console.log("finished instanciating mqtt module");
}
chunkSubstr(str, size) {
var numChunks = Math.ceil(str.length / size),
chunks = new Array(numChunks);
for(var i = 0, o = 0; i < numChunks; ++i, o += size) {
chunks[i] = str.substr(o, size);
}
return chunks;
}
};
var myMqttTest = new MqttTest();
console.log("loaded mqtt-test module");
from aedes.
@cordovapolymer I wasn't able to detect any problem at my end. Is the receiver is offline when these messages are published ? If so, try using clean false. Also it would be a good idea to defer your publishes to on connect-Just a suggestion
.
from aedes.
@cordovapolymer it seems your code is supposed to be used required by some other module? Can you make it so that we can just run it?
It would be easier to reproduce the problem.
from aedes.
@GavinDmello, @mcollina , I've updated the code to run standalone. Narrowing the problem- as I've found out 2773 messages are successfully received via mqtt protocol, but are not via websocket.
I'm using standart mqtt.js client.
When changing maximum message length in if(jsonMessage.length >= 2048){ var messageChunks = this.chunkSubstr(jsonMessage, 2048);
to 204800 bytes, 28 messages are successfully received both via mqtt and websocket.
from aedes.
On my tests, I am getting exactly 2773 messages over ws. Can you please a full project that exhibit this issue? Is this happening on the browser?
from aedes.
@mcollina
I will publish it a bit later because I'll have to prepare it, last week I've been trying to solve another issue which I'm going to publish right now.
from aedes.
Ping, any update on the example to replicate?
from aedes.
Related Issues (20)
- [question] Connecting to AEDES with Certificates HOT 1
- Aedes handle, client not connected HOT 1
- Why is CONNACK returned before the end of on.connect HOT 2
- [question] Kotlin Android examples
- Difficult to use in ES6 module package. HOT 10
- [question] How to get client ip address in Websocket mode HOT 1
- [feat!]: change to named exports to enable monkey patching HOT 11
- [question] Parsing a packet that come from old mqtt client version HOT 5
- Can Aedes send webhooks? HOT 2
- [bug] - TypeError during aedes Module Initialization
- mqtt服务启动后无法打印内容 HOT 2
- [bug] Aedes is undefined in Typescript HOT 7
- [bug] duplicated closed clients HOT 1
- [bug]"done" is not a function
- [question] does the test "unsubscribe throws error" valid? HOT 3
- [question] Any way to add data to connect packet and authorize handler? HOT 2
- [question]Frequent service clientError Error: invalid status code: 12592 HOT 1
- [bug] Number of TCP Connections accepted on container is less than the one deployed in EC2 machine HOT 7
- [bug] console.error introduced in v0.51.0 HOT 1
- [bug] Not all messages are consumed when dedupe is enabled HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aedes.