How to implement Node.Js server-side event server for Firebase?

I am trying to listen for data changes in my firebase using the firebase package for Node. I use the on () method, which should listen for changes without stopping (unlike the once () method, which only listens for the first occurrence of a specific event). My listener.js file on the server is exactly like this:

var Firebase=require('firebase');
var Ref= new Firebase('https://mydatabase.firebaseio.com/users/');
 Ref.on('child_changed',function(childsnapshot,prevchildname){
 Ref.child(childsnapshot.key()).push("I hear you!");

} ) ;

But it works only for the first appearance and produces a fatal memory error after the second occurrence.

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - process out of memory

I am very new to server-side programming and don't know what to do. I have to miss something important. Should I first configure the server settings using node? or perhaps make a daemon that runs the script method with the once () method every second or so?

+4
1

, :

  • https://mydatabase.firebaseio.com/users/
  • on('child_changed' script
  • script
  • 2

, Firebase .

, -. , , , :

var Firebase=require('firebase');
var ref= new Firebase('https://mydatabase.firebaseio.com/users/');
ref.on('child_changed',function(childsnapshot,prevchildname){
  ref.push("I hear you!");
}) ;

, StackOverflow . , , Windows, Visual Studio node. , . ( ref.push) , .

+3

All Articles