2013-07-14 57 views
0

我在Android上运行node.js v0.11(通过https://github.com/paddybyers/node)。我试图尝试在这里找到的“Hello HTTP”示例:http://howtonode.org/hello-node,但是,我遇到了问题。Android上的HTTP服务器通过node.js请求错误

服务器启动正常,但只要我试图(通过访问http://localhost:8000/)连接到HTTP服务器,我得到这个错误:

net.js:1156 
    COUNTER_NET_SERVER_CONNECTION(socket); 
^
ReferenceError: COUNTER_NET_SERVER_CONNECTION is not defined 
    at TCP.onconnection (net.js:1156:3) 

我的代码是完全一样的Hello HTTP例子:

//Load the http module to create an http server. 
var http = require('http'); 

// Configure our HTTP server to respond with Hello World to all requests. 
var server = http.createServer(function (request, response) { 
    response.writeHead(200, {"Content-Type": "text/plain"}); 
    response.end("Hello World\n"); 
}); 

// Listen on port 8000, IP defaults to 127.0.0.1 
server.listen(8000); 

// Put a friendly message on the terminal 
console.log("Server running at http://127.0.0.1:8000/"); 

我该如何解决这个问题?

谢谢!

+0

你能告诉我服务器的错误日志吗? – Rikky

+0

这是服务器的错误日志。 – aegamesi

回答

0

使用HAVE_PERFCTR选项编译Node.js。 (您需要为Android实现您自己的perfctrs,请参阅node_counters.cc第130行)。

也应该可以在脚本中将缺少的函数定义为空函数。

PS: 您还需要DTRACE。

0

我只是注释掉所有COUNTER_NET_ ,COUNTER_HTTP_,DTRACE_NET_ 和DTRACE_HTTP_电话下的lib/JavaScript文件。这大约有10条左右的线,我从net.js和http.js中注释掉了。

我认为js2c.py应该处理src/macros.py和src/perfctr_macros.py,以便在将/ lib下的脚本序列化为out/release中的C数组时,为您有效地为您做'注释' /src/node_natives.h,但似乎没有发生。

相关问题