I'm trying to make a mp3 webradio in node.js using the child_process module and the mpg123 player on a raspberry pi.
Here's the problem: When I try to write to a stream, I always get an Error:
Error: write EPIPE
at exports._errnoException (util.js:1026:11)
at WriteWrap.afterWrite (net.js:795:14)
Here's what I tried to test it:
//create a subprocess
var test = childProcess.exec('ls /home/pi/music');
//pipe all the output to the process output
test.stdout.pipe(process.stdout);
test.stderr.pipe(process.stderr);
test.stdin.setEncoding('utf-8');
//here I just want to write a key to the subprocess
test.stdin.write('q');
test.stdin.end()
Anyone know, what to do, that the created write stream will not be closed until everything is done?
And of course I still searched on google for this:
Child_process throw an Error: write EPIPE
https://github.com/nodejs/node/issues/2985
https://nodejs.org/api/child_process.html#child_process_subprocess_stdin
https://nodejs.org/api/stream.html#stream_writable_write_chunk_encoding_callback
Please help!
.end()the stind stream while it has already been ended on the other side ? - n00dl3