Not a duplicate of : this question, as I'm trying to use the link posted as answer to solve my problem.
I'm creating a little dummy socket client to help testing one of my product, it looks like so :
var ee = require('events').EventEmitter;
require('http').globalAgent.maxSockets = 1000;
function Dummy(){
this.config = require('../config/credentials.js');
this.socket = require('socket.io-client')(this.config.socketIO.url);
var self = this;
this.socket.on('task', function(task) {
self.createTask(task);
});
}
util.inherits(Dummy, ee);
module.exports = Dummy;
Dummy.prototype.createTask = function(name){
var self = this;
setInterval(function sendStuff(){
self.socket.emit("msg")
}, 1000);
};
On its own, it works fine; However, when I try to launch many of them like so :
for (var i = 0; i < 100; i++) {
fakeClients.push(new Dummy());
};
Is appears to pool connections and shows as one client only. Based on this link, I thought that by using socket.io-client, I'd avoid the pooling behaviour, yet it doesn't work. Am I doing something wrong? I've simplified the loop btw, I actually make sure there's a delay between creations to avoid sync heartbeats.
Ideas?
Aucun commentaire:
Enregistrer un commentaire