GraftJS / graft

full-stack javascript through microservices
http://graft.io
MIT License
227 stars 15 forks source link

io.js v2.4.0 error #19

Closed boneskull closed 9 years ago

boneskull commented 9 years ago

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 commented 9 years ago

closed in lieu of GraftJS/jschan#36