I have already tried all the methods, I can not stop the timer on the nodejs server. Tried different options with setInterval and setTimeout. I always get a working timer.
function myTimer(room,step){ holand.get(room, function(err, reply) { console.log(reply); var newcena = reply - step; console.log('New price '+newcena); holand.set(room, newcena); socket.emit('iscena', newcena.toFixed(2)); }); } var timerId; console.log('1 '+timerId); socket.on('howcena', function(data){ var room = data.room; var step = data.step; console.log(room); console.log(step); timerId = setTimeout(function tick() { myTimer(room,step); timerId = setTimeout(tick, 5000); }, 5000); console.log('2 '+timerId); }); socket.on('stopcena',function(data){ clearTimeout(timerId); console.log('3 '+timerId); console.log('Stop timer'); });