Why does this structure makes the app consuming more and more memory? And how do i prevent it? It runs on Windows...
this.connectClient is only called ONCE. connectClient() is called as you can see recursively.
this.connectClient = function() {
connectClient();
function connectClient() {
_ws.on('open', function open() {
...
});
_ws.on('message', function (data, flags) {
...
});
_ws.on('close', function close() {
...
});
_ws.on('error', function error(err) {
setTimeout(function(){
_ws = new WebSocket('ws://localhost:4080');
setImmediate(connectClient);
// or just connectClient(); makes no difference
}, 5000);
});
}
}
via PabloDK
No comments:
Post a Comment