piping to a spawn stdin

Viewed 1588

I would like to pipe some streaming data to feedgnuplot in order to graph it in real time

The following works:

// index.js
readableStream.pipe(process.stdout)

// in bash
$ node index.js | feedgnuplot --stream

But the following doesn't work (and this is what I want to make work):

// index.js
var feedgnuplot = require('child_process').spawn('feedgnuplot', ['--stream'])
readableStream.pipe(feedgnuplot.stdin)

//in bash
$ node index.js

I get an ECONNRESET error

EDIT: example of a readable stream as requested:

var util = require('util')
var Readable = require('stream').Readable

util.inherits(SomeReadableStream, Readable)

function SomeReadableStream () {
  Readable.call(this)
}

SomeReadableStream.prototype._read = function () {
  this.push(Math.random().toString()+'\n')
}

var someReadableStream = new SomeReadableStream()

someReadableStream.pipe(process.stdout)
1 Answers
Related