Troubleshooting Error: connect ECONNREFUSED in nodejs stream

I've been working through the learnyoujs and stream-adventure tutorials:

https://github.com/substack/stream-adventure

https://github.com/rvagg/learnyounode#learn-you-the-nodejs-for-much-win

I've gotten all the way through the first set and most of the way thorough the second, but I keep getting an odd error... usually I can get it to go away.

Here's the command/error:

DEV/javascript/streamAdventure » stream-adventure run httpserver.js

stream.js:94
  throw er; // Unhandled stream error in pipe.
        ^
Error: connect ECONNREFUSED
  at errnoException (net.js:901:11)
  at Object.afterConnect [as oncomplete] (net.js:892:19)

This will launch but not kill the process for node, so I ps aux | grep node and then find the process and kill it.

Here's the "working" code from the tutorial:

var http = require('http');
var through = require('through');

var server = http.createServer(function (req, res) {
    if (req.method === 'POST') {
        req.pipe(through(function (buf) {
            this.queue(buf.toString().toUpperCase());
        })).pipe(res);
    }
    else res.end('send me a POSTn');
});
server.listen(8000);

If I just run nod httpserver.js and then curl at it, it works fine.... so does anyone have any insight into what is causing this error?


There is a pull request to fix this, here: https://github.com/substack/stream-adventure/pull/16

Try to listen on port 8001 instead and rerun verify after closing all processes listening on 8000.


I had the same error, problem wasn't with though node however, it was with mysql. Ran "mysqld_safe restart" (depends on your version), then it worked fine.

链接地址: http://www.djcxy.com/p/15290.html

上一篇: 为Atlassian Bamboo制作钥匙串证书

下一篇: 故障排除错误:在nodejs流中连接ECONNREFUSED