简体   繁体   中英

Node.js and SPDY … not working?

I can't seem to get node.js (v0.8.2) to work with spdy (v1.2.1). Here's my code in coffeescript because it's cool:

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

I see "Server running on 8000", but when trying to connect to 127.0.0.1:8000 in Chrome, I get nothing, and "request made..." never goes off.

Thanks so much guys!!

Make sure you're accessing it via HTTPS. Aka: https://127.0.0.1:8000/ (works fine here)

SPDY is negotiated over SSL NPN, which means your server is only accessible via HTTPS protocol.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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