0

The problem that I'm facing currently is the server continuously is pushing binary data through TCP port, I'm able to read these data but the problem is when the data is too large my app is crashing because can't close properly the object. The application is built in node JS and I tried to use json-stream but without success.

EXAMPLE:

var client = new net.Socket();
client.connect(PORT, HOST, function() {
 console.log('CONNECTED TO: ' + HOST + ':' + PORT); 
}
client.on('data', function(data) {
  var readyToExplore = JSON.parse(data.toString());
  console.log(readyToExplore);
}

The app will crash if try to parse to JSON but if left as a data.toString() then it's not a problem.

Rahul Sharma
  • 1,393
  • 10
  • 19
imcze
  • 389
  • 2
  • 4
  • 13

1 Answers1

1

Give node more memory.

node --max-old-space-size=8192 server.js  

See how to increase nodejs default memory?

Steven Spungin
  • 27,002
  • 5
  • 88
  • 78