Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

io.js v2.4.0 error #19

Closed
boneskull opened this issue Jul 23, 2015 · 1 comment
Closed

io.js v2.4.0 error #19

boneskull opened this issue Jul 23, 2015 · 1 comment

Comments

@boneskull
Copy link

given a spdy server created with graft/spdy on port 3447, I have this client code, modeled after the example in README.md:

'use strict';

let graft = require('graft')();
let spdy = require('graft/spdy');

let time = graft.WriteChannel();

graft.pipe(spdy.client({ port: 3447 }));

graft.write({
  topic: 'register',
  id: 'time',
  data: time
});

setInterval(function() {
  time.write(new Date());
}, 1000);

(mind you, I have no idea if this code does what I think it does, because...)

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/graft/node_modules/jschan/lib/spdy/client.js:104:18)
    at createChannel (/Volumes/alien/projects/digs/digs-graft/node_modules/graft/node_modules/jschan/lib/spdy/client.js:142:11)
    at ClientSession.WriteChannel (/Volumes/alien/projects/digs/digs-graft/node_modules/graft/node_modules/jschan/lib/spdy/client.js:156: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)

UPDATE: I realize this may be the fault of the server code. Here's the server, in all its glory:

'use strict';

process.env.DEBUG = 'digs-graft*';

let graft = require('graft');
let spdy = require('graft/spdy');
let rc = require('rc-yaml');
let through = require('through2');
let pkg = require('./package.json');
let domain = require('domain');
let debug = require('debug')('digs-graft');

let cfg = rc(pkg.name, {
  port: 3447
});

let digs = graft();
let router = graft();

function data() {
  return through.obj(function(msg, enc, done) {
    let debug = require('debug')('digs-graft:data');
    debug(msg);
  });
}

function register() {
  return through.obj(function(msg, enc, done) {
    let debug = require('debug')('digs-graft:register');
    debug(`client ${msg.id} registered`);

    let d = domain.create();
    d.on('error', function(err) {
      debug(err);
    });
    d.run(function() {
      router.branch(function() {
        return msg.data; // branch if data property is truthy
      }, data());
    });
  });
}

digs.where({
  topic: 'register'
}, register());

spdy.server({
  port: cfg.port
})
    .pipe(digs);
@boneskull
Copy link
Author

closed in lieu of GraftJS/jschan#36

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant