I'm relatively new to node and im struggling to find the answers!
I've created a very basic node script that is used to connect to a rs232 serial device, at the same time it serves as a websocket server so that clients can connect to it to get live output from the rs232 device but i keep getting event emitter max listeners errors after 11 clients have connected.
If any one can help me here or if i've gone about the code the wrong way give some advice it would be appreciated.
Thanks Jamie
heres the code
var serialport = require("serialport");
var SerialPort = serialport.SerialPort;
var WebSocketServer = require("ws").Server;
var serialPort = new SerialPort("COM5", {
baudrate: 9600,
parser: serialport.parsers.readline("\n")
});
var wss = new WebSocketServer({ port: 3000 });
serialPort.on("open", function () {
console.log('open');
var weight = 0;
wss.on("connection", function(ws) {
serialPort.on('data', function(data) {
weight = data.toString();
wss.clients.forEach(function(wssclient) {
wssclient.send(weight);
});
});
});
});