简体   繁体   English

根据要求通过node.js在Android上进行HTTP Server错误

[英]HTTP Server on Android via node.js errors upon request

I'm running node.js v0.11 on Android (via https://github.com/paddybyers/node ). 我在Android上运行node.js v0.11(通过https://github.com/paddybyers/node )。 I attempted to try out the "Hello HTTP" example found here: http://howtonode.org/hello-node , however, I ran into problems. 我尝试尝试在此处找到“ Hello HTTP”示例: http : //howtonode.org/hello-node ,但是,我遇到了问题。

The server starts fine, but as soon as I attempt to connect to the http server (by visiting http://localhost:8000/ ), I get this error: 服务器启动正常,但是一旦我尝试连接到http服务器(通过访问http://localhost:8000/ ),就会出现此错误:

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

My code is exactly the same as the Hello HTTP example: 我的代码与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/");

How can I fix this? 我怎样才能解决这个问题?

Thanks! 谢谢!

Compile Node.js with the HAVE_PERFCTR option. 使用HAVE_PERFCTR选项编译Node.js。 (You Need to implement your own perfctrs for Android. See node_counters.cc line 130). (您需要为Android实现自己的性能。请参见node_counters.cc第130行)。

It should be also possible to define the missing functions in your script as empty functions. 还应该可以将脚本中缺少的函数定义为空函数。

PS.: You also need DTRACE. PS .:您还需要DTRACE。

I simply commented out all COUNTER_NET_ , COUNTER_HTTP_ , DTRACE_NET_ , and DTRACE_HTTP_ calls in the javascript files under lib/. 我只是注释掉lib /下的javascript文件中的所有COUNTER_NET_ ,COUNTER_HTTP_ ,DTRACE_NET_ 和DTRACE_HTTP_调用。 This amounted to about 10 or so lines that I commented out of net.js and http.js. 我从net.js和http.js中注释掉了大约10行。

I think that js2c.py is supposed to process src/macros.py and src/perfctr_macros.py to effectively do this 'commenting out' for you when it serializes the scripts under lib/ to C arrays in out/release/src/node_natives.h, but that doesn't seem to be happening. 我认为js2c.py应该在将lib /下的脚本序列化为out / release / src / node_natives中的C数组时,对src / macros.py和src / perfctr_macros.py进行有效的“注释”操作.h,但这似乎没有发生。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM