spdy-http2 / node-spdy

SPDY server on Node.js
2.8k stars 196 forks source link

Getting `socket hang up` when using plain:true, ssl:false #219

Closed groundwater closed 9 years ago

groundwater commented 9 years ago

I am trying to use both client/server without SSL. I am not using a browser at the moment.

I think I am doing it right, but am getting

events.js:141
      throw er; // Unhandled 'error' event
      ^

Error: socket hang up
    at createHangUpError (_http_client.js:203:15)
    at Stream.socketCloseListener (_http_client.js:235:23)
    at emitOne (events.js:82:20)
    at Stream.emit (events.js:169:7)
    at Immediate._onImmediate (/Users/jacob/Projects/source.datanerd.us/jacob/mobius/node_modules/spdy/lib/spdy/stream.js:450:12)
    at processImmediate [as _immediateCallback] (timers.js:371:17)

Source (in ES6)

import spdy from 'spdy'
import http from 'http'

const options = {
  spdy: {
    plain : true,
    ssl   : false,
  },
}

spdy.createServer(options, function(req, res) {
  console.log(req)
})
.listen(8080, function(){
  console.log('server listening')

  var agent = spdy.createAgent({
    host: 'localhost',
    port: 8080,

    spdy: {
      plain: true,
      ssl: false,
    },
    plain: true, // not sure which way is right
    ssl: false,
  })

  var req = http.get({
    host  : 'localhost',
    port  : 8080,
    agent : agent,
  })

})
indutny commented 9 years ago

@groundwater oh... looks like Agent does not support plain mode yet. I'll figure it out today

groundwater commented 9 years ago

@indutny much appreciated :balloon: I'll give it a hack too

groundwater commented 9 years ago

My poor workaround was to change this line to http https://github.com/indutny/node-spdy/blob/master/lib/spdy/agent.js#L236

groundwater commented 9 years ago

hmm... While I no longer get errors. That doesn't seem to work.

indutny commented 9 years ago

Should be fixed now! PTAL ;)