这是一个简单的代码示例:
var https = require('https');
var fs = require('fs');
var options = {
key: fs.readFileSync("./ssl/key.pem"),
cert: fs.readFileSync("./ssl/cert.pem")
};
https.createServer(options, function (req, res) {
res.writeHead(200);
res.end("hello world\n");
}).listen(443);
对localhost:443的所有请求都会导致无限待审。
我通过以下方式运行此示例:" sudo nodejs https.js"
未发现任何错误/警告。 443端口有一个"听力"州。 https://www.dropbox.com/s/uchpbn0ifacmf4x/node.jpg?dl=0
在我的linux和Windows机器上重现问题。
我也试过了名为" pem"结果相同。
http
在我的环境中正常工作。
节点版本:0.10.33
你能帮助我解决问题吗?可能我可以激活更多调试吗?
更新:strace
{{EPOLLIN, {u32=10, u64=10}}}, 1024, 119999) = 1
clock_gettime(CLOCK_MONOTONIC, {1989619, 754364596}) = 0
accept4(10, 0, NULL, SOCK_CLOEXEC|SOCK_NONBLOCK) = 11
futex(0x7f577c0008c8, FUTEX_WAKE_PRIVATE, 1) = 1
gettimeofday({1418596391, 472239}, NULL) = 0
futex(0x7f577c0008c8, FUTEX_WAKE_PRIVATE, 1) = 1
gettimeofday({1418596391, 472445}, NULL) = 0
accept4(10, 0, NULL, SOCK_CLOEXEC|SOCK_NONBLOCK) = -1 EAGAIN (Resource temporarily unavailable)
clock_gettime(CLOCK_MONOTONIC, {1989619, 755788224}) = 0
epoll_ctl(5, EPOLL_CTL_ADD, 11, {EPOLLIN, {u32=11, u64=11}}) = 0
epoll_wait(5, {{EPOLLIN, {u32=11, u64=11}}}, 1024, 119999) = 1
clock_gettime(CLOCK_MONOTONIC, {1989619, 755916479}) = 0
read(11, "GET / HTTP/1.1\r\nHost: localhost"..., 65536) = 583
gettimeofday({1418596391, 472940}, NULL) = 0
clock_gettime(CLOCK_MONOTONIC, {1989619, 756589265}) = 0
futex(0x7f577c0008c8, FUTEX_WAKE_PRIVATE, 1) = 1
epoll_wait(5, {{EPOLLIN, {u32=10, u64=10}}}, 1024, 119999) = 1
clock_gettime(CLOCK_MONOTONIC, {1989619, 758012624}) = 0
accept4(10, 0, NULL, SOCK_CLOEXEC|SOCK_NONBLOCK) = 12
futex(0x7f577c0008c8, FUTEX_WAKE_PRIVATE, 1) = 1
gettimeofday({1418596391, 475378}, NULL) = 0
gettimeofday({1418596391, 475522}, NULL) = 0
gettimeofday({1418596391, 475798}, NULL) = 0
gettimeofday({1418596391, 475836}, NULL) = 0
gettimeofday({1418596391, 476235}, NULL) = 0
gettimeofday({1418596391, 476272}, NULL) = 0
brk(0x12c0000) = 0x12c0000
brk(0x1300000) = 0x1300000
mmap(0x8138ef00000, 20480, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x8138ef00000
mprotect(0x8138ef05000, 4096, PROT_NONE) = 0
mmap(0x8138ef06000, 1019904, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x8138ef06000
mprotect(0x8138efff000, 4096, PROT_NONE) = 0
gettimeofday({1418596391, 478274}, NULL) = 0
futex(0x7f577c0008c8, FUTEX_WAKE_PRIVATE, 1) = 1
gettimeofday({1418596391, 478657}, NULL) = 0
accept4(10, 0, NULL, SOCK_CLOEXEC|SOCK_NONBLOCK) = -1 EAGAIN (Resource temporarily unavailable)
clock_gettime(CLOCK_MONOTONIC, {1989619, 762218983}) = 0
epoll_ctl(5, EPOLL_CTL_ADD, 12, {EPOLLIN, {u32=12, u64=12}}) = 0
epoll_wait(5, ^CProcess 15474 detached
更新:我使用的是digitalocean droplet
Ubuntu 14.04 x64 vmlinuz-3.13.0-24-generic(1221)
Linux r___t.ru 3.13.0-24-generic#46-Ubuntu SMP Thu Apr 10 19:11:08 UTC 2014 x86_64 x86_64 x86_64 GNU / Linux
答案 0 :(得分:0)
... Hhha
此问题的根本原因是请求“ http :// localhost:443”而不是“http s :// localhost”。