【问题标题】:Node.js and SPDY ... not working?Node.js 和 SPDY ...不工作?
【发布时间】:2012-07-17 00:53:00
【问题描述】:

我似乎无法让 node.js (v0.8.2) 与 spdy (v1.2.1) 一起使用。这是我在咖啡脚本中的代码,因为它很酷:

spdy = require 'spdy'
fs = require 'fs'

DEFAULT_PORT = 8000

DEFAULT_SERVER_OPTIONS =
  key: fs.readFileSync(__dirname + '/keys/privatekey.pem')
  cert: fs.readFileSync(__dirname + '/keys/certificate.pem')
  ca: fs.readFileSync(__dirname + '/keys/certrequest.csr') 

spdy.createServer DEFAULT_SERVER_OPTIONS, (request, response) ->
    console.log 'request made...'
    response.writeHead 200
    response.write 'goodbye cruel world'
    response.end()
.listen DEFAULT_PORT
console.log 'Server running on ' + DEFAULT_PORT

我看到“服务器在 8000 上运行”,但在 Chrome 中尝试连接到 127.0.0.1:8000 时,我什么也得不到,而且“发出的请求...”永远不会消失。

非常感谢大家!!

【问题讨论】:

  • 如果您连接到机器的 LAN IP(不是 127.0.0.1)会发生什么?例如:铬:192.168.100.1:8000

标签: node.js spdy


【解决方案1】:

确保您通过 HTTPS 访问它。又名:https://127.0.0.1:8000/(在这里可以正常工作)

SPDY 是通过 SSL NPN 协商的,这意味着您的服务器只能通过 HTTPS 协议访问。

【讨论】:

    猜你喜欢
    • 2012-12-18
    • 2013-07-21
    • 2016-01-15
    • 2014-08-12
    • 1970-01-01
    • 1970-01-01
    • 2013-06-09
    • 2012-06-02
    • 2017-05-31
    相关资源
    最近更新 更多