Search code examples
node.jsfirebasesetintervalfirebase-hosting

setinterval Stops Working After 540 seconds (time limit in Firebase hosting), How to Solve this?


I've been using NodeJS running on Firebase hosting to monitor sensor values (through dedicated hardware). I simply use function setinterval to check the sensor values via API that I wrote. The system reads from sensor successfully for every minutes (for just testing) but it stops reading after 9 minutes (or 540 seconds according to google document here ??). The reading sensor function is working, only the loop in setinterval that stops working as I've mentioned. My simple code looks like this:

var intervalObj = setinterval(function(sensor_id){
      var val = readSensorValue(sensor_id);    
      var d = new Date();
      console.log("reading from sensor[" + sensor_id + "] => " + val + "@" + d);
   }, 60000);

However, I have to monitor the sensor all day long. How can I fix this?? Or there's any other better approach??

Thank you for your time,

JJ

:D:D:D


Solution

  • I've decided not to use Firebase function hosting for now, so I run the project on the VM and everything's been working fine. Just a simple setInterval... even though I'm still wonder whether it is a design by Firebase for such limitation or there should be other approach for doing this on Firebase.

    Thanks for all the comment. :D:D:D