Nowjs : running node and nowjs on a hosted server - error : maximum call stack size exceeded

StackOverflow https://stackoverflow.com/questions/10896167

  •  12-06-2021
  •  | 
  •  

Question

Hello fellow stackers.

I am implementing node.js and nowjs on a website I am working on. I started developing the site weeks ago on localhost and everything was working fine. I transferred the files couple of days ago to a cloud server hosted by rackspace with Ubuntu 12.04 LTS (Precise Pangolin) as OS.

Now I cant get the simple chat example on the nowjs home page to work! I keep getting the following error when I try to run the server side script :

[RangeError: Maximum call stack size exceeded]

There are no recursive loops in my code and I have tried looking for solutions for my problem all over the internet with no luck.

Here are my two example files - a c/p from the chat/helloworld example at the official nowjs site. (http://nowjs.com/doc/example)

server.js

var html = require('fs').readFileSync(__dirname+'/helloworld.html');
var server = require('http').createServer(function(req, res){
  res.end(html);
});
server.listen(8080);

var nowjs = require("now");
var everyone = nowjs.initialize(server);

everyone.now.distributeMessage = function(message){
  everyone.now.receiveMessage(this.now.name, message);
};

helloworld.html

<!DOCTYPE html>
<html lang="en">
<head>
<title>nowjs test</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
<script src="/nowjs/now.js"></script>

<script>
$(document).ready(function(){

  now.receiveMessage = function(name, message){
    $("#messages").append("<br>" + name + ": " + message);
  }

  $("#send-button").click(function(){
    now.distributeMessage($("#text-input").val());
    $("#text-input").val("");
  });

  now.name = prompt("What's your name?", "");

});
</script>
</head>

<body>
  <div id="messages"></div>
  <input type="text" id="text-input">
  <input type="button" value="Send" id="send-button">
</body>
</html>

My questions :

  1. Has anyone had the same problem running nowjs on a hosted web server?
  2. Are there any dependencies that I might not be aware of when running nowjs on a hosted web server?

Thank you.

Was it helpful?

Solution

I finally resolved this. All that needed was a reinstallation of node with the most recent stable version(v0.4.12).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top