GraftJS / jschan

JavaScript port of libchan based around streams
MIT License
157 stars 9 forks source link

protocol error w/ io.js 2.40 #36

Closed boneskull closed 9 years ago

boneskull commented 9 years ago

see GraftJS/graft#19

events.js:141
      throw er; // Unhandled 'error' event
            ^
Error: Protocol "http:" not supported. Expected "https:".
    at new ClientRequest (_http_client.js:53:11)
    at Object.exports.request (http.js:31:10)
    at ClientSession.newStream [as _createNewStream] (/Volumes/alien/projects/digs/digs-graft/node_modules/jschan/lib/spdy/client.js:104:18)
    at createChannel (/Volumes/alien/projects/digs/digs-graft/node_modules/jschan/lib/spdy/client.js:143:11)
    at ClientSession.WriteChannel (/Volumes/alien/projects/digs/digs-graft/node_modules/jschan/lib/spdy/client.js:157:10)
    at SPDYClient.Client._write (/Volumes/alien/projects/digs/digs-graft/node_modules/graft/lib/client.js:36:30)
    at doWrite (/Volumes/alien/projects/digs/digs-graft/node_modules/graft/node_modules/readable-stream/lib/_stream_writable.js:279:12)
    at writeOrBuffer (/Volumes/alien/projects/digs/digs-graft/node_modules/graft/node_modules/readable-stream/lib/_stream_writable.js:266:5)
    at SPDYClient.Writable.write (/Volumes/alien/projects/digs/digs-graft/node_modules/graft/node_modules/readable-stream/lib/_stream_writable.js:211:11)
    at Graft.ondata (/Volumes/alien/projects/digs/digs-graft/node_modules/graft/node_modules/readable-stream/lib/_stream_readable.js:572:20)
boneskull commented 9 years ago

working on PR

boneskull commented 9 years ago

nevermind, can't figure it out. there's some disagreement between the latest version of spdy, io.js, and jschan.

I'm getting a bunch of this:

TypeError: Cannot read property 'session' of undefined
    at Server.<anonymous> (/Volumes/alien/projects/boneskull/jschan/lib/spdy/server.js:178:43)
    at emitTwo (events.js:87:13)
    at Server.emit (events.js:172:7)
    at Connection.onrequest (/Volumes/alien/projects/boneskull/jschan/node_modules/spdy/lib/spdy/server.js:293:10)
    at emitTwo (events.js:87:13)
    at Connection.emit (events.js:172:7)
    at HTTPParser.parserOnIncoming [as onIncoming] (_http_server.js:473:12)
    at HTTPParser.parserOnHeadersComplete (_http_common.js:88:23)
    at Stream.start [as _start] (/Volumes/alien/projects/boneskull/jschan/node_modules/spdy/lib/spdy/stream.js:249:23)
    at Connection.handleSynStream [as _handleSynStream] (/Volumes/alien/projects/boneskull/jschan/node_modules/spdy/lib/spdy/connection.js:299:10)
    at Connection.handleFrame [as _handleFrame] (/Volumes/alien/projects/boneskull/jschan/node_modules/spdy/lib/spdy/connection.js:182:19)
    at emitOne (events.js:77:13)
    at Parser.emit (events.js:169:7)
    at onFrame (/Volumes/alien/projects/boneskull/jschan/node_modules/spdy/lib/spdy/protocol/parser.js:232:12)
    at /Volumes/alien/projects/boneskull/jschan/node_modules/spdy/lib/spdy/protocol/parser.js:333:5
    at /Volumes/alien/projects/boneskull/jschan/node_modules/spdy/lib/spdy/protocol/parser.js:427:5
    at done (/Volumes/alien/projects/boneskull/jschan/node_modules/spdy/lib/spdy/utils.js:111:7)
    at afterWrite (_stream_writable.js:346:3)
    at onwrite (_stream_writable.js:337:7)
    at WritableState.onwrite (_stream_writable.js:89:5)
    at afterTransform (_stream_transform.js:79:5)
    at TransformState.afterTransform (_stream_transform.js:54:12)
    at Zlib.callback (zlib.js:614:5)

When I try to use req.connection.socket.getSession(), that doesn't work either because it's not the same socket from the connection event, so _receive is undefined.

In ClientSession.prototype._createNewStream(), I did this:

  var req = http.request({
    host: this.opts.host,
    port: this.opts.port,
    path: '/',
    headers: headers,
    method: 'POST',
    agent: this.agent,
    protocol: 'https:' // <-- this
  }, function(res) {
    chan.handleIn(res);
  });

to avoid the original exception, but I think that alters how spdy works, leading to this other issue

boneskull commented 9 years ago

perhaps jschan should drop spdy altogether:

https://github.com/nodejs/NG/issues/8

AdrianRossouw commented 9 years ago

I think that's the plan, but we were waiting for a proper http2 implementation to be available.

mcollina commented 9 years ago

We have: https://github.com/indutny/spdy-transport

AdrianRossouw commented 9 years ago

i moved the spdy support to https://github.com/GraftJS/jschan-spdy, so we can switch out when needed.

this should also not stop you from using jschan anymore.