linux - Socket.IO Websocket 服务器超出最大调用堆栈大小

标签 linux apache node.js socket.io

我正在尝试让 websocket 服务器在我的 Debian Linux 服务器上运行。我遵循了很多教程,但现在我遇到了一个错误:

我正在学习本教程 http://codehenge.net/blog/2011/05/getting-started-with-node-js-and-socket-io-part-2/尝试显示 (hello) 时一切正常,但当我尝试包含 Socket.IO 时出现此错误。

info  - socket.io started

/usr/local/lib/node_modules/socket.io/lib/manager.js:0
(function (exports, require, module, __filename, __dirname) { /*!
^
RangeError: Maximum call stack size exceeded

有什么想法吗?

套接字测试.js

 var http = require('http')
, url = require('url')
, fs = require('fs')
, server;

server = http.createServer(function(req, res){
// your normal server code
var path = url.parse(req.url).pathname;
switch (path){
case '/':
res.writeHead(200, {'Content-Type': 'text/html'});
res.write('<h1>Hello! Try the <a href="/socketio-test.html">Socket.io Test</a></h1>');
res.end();
break;
case '/socketio-test.html':
fs.readFile(__dirname + path, function(err, data){
if (err) return send404(res);
res.writeHead(200, {'Content-Type': path == 'json.js' ? 'text/javascript' : 'text/html'})
res.write(data, 'utf8');
res.end();
});
break;

default: send404(res);
}
}),

send404 = function(res){
res.writeHead(404);
res.write('404');
res.end();
};

server.listen(8080);

// socket.io, I choose you
var io = require('/usr/local/lib/node_modules/socket.io').listen(server);

// on a 'connection' event
io.sockets.on('connection', function(socket){

  console.log("Connection " + socket.id + " accepted.");

  // now that we have our connected 'socket' object, we can 
  // define its event handlers
  socket.on('message', function(message){
        console.log("Received message: " + message + " - from client " + socket.id);
  });

  socket.on('disconnect', function(){
    console.log("Connection " + socket.id + " terminated.");
  });

});

最佳答案

更新:我发现问题了!我使用的是不稳定版本的 Node 。我只是使用稳定的重新安装,现在一切都很好!

关于linux - Socket.IO Websocket 服务器超出最大调用堆栈大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9985446/

相关文章:

c++ - make : error adding symbols: DSO missing from command line 时出错

linux - 从脚本运行时,Bash 脚本无法正确执行命令

node.js - `fs-extra` 与 `bluebird ` 集成得到 `Cannot read property ' 然后 ' of undefined` 错误

node.js - 如何访问node.js应用程序的coffee脚本文件的内部结构?

windows - Windows 框上的 nodejs 上的 persistence.js

linux - Bash 脚本问题

linux - xargs : "bash -c" does not pass arguments to command 中的 bash 别名

php - UTF-8贯穿始终

Apache mod_rewrite 用于除 root 之外的所有内容

linux - php 脚本刚刚用垃圾填满了硬盘驱动器我如何找到它?