crashes about once a day #32

Open
keverw opened this Issue Jun 24, 2012 · 5 comments

Comments

Projects
None yet
3 participants

keverw commented Jun 24, 2012

I'm using the command line version with a routes.json, and about once a day it crashes. I'm using the lastest Ubuntu LTS and Node.js. I'm running the current version from NPM.

events.js:48
        throw arguments[1]; // Unhandled 'error' event
        ^
Error: write EPIPE
    at errnoException (net.js:670:11)
    at Object.afterWrite [as oncomplete] (net.js:503:19)

keverw commented Jun 24, 2012

{
    "enyo.biz" : 3121,
    "www.enyo.biz" : 3121,
    "dev.enyo.biz" : 3121,
    "www.dev.enyo.biz" : 3121,
    "igeekable.com" : 3121,
    "www.igeekable.com" : 3121,


    "keverw.com" : 3121,
    "www.keverw.com" : 3121,

    "arcade4playing.com" : 3121,
    "www.arcade4playing.com" : 3121,

    "viewashi.com" : 3121,
    "www.viewashi.com" : 3121,

    "pier.viewashi.com" : 3121,
    "www.pier.viewashi.com" : 3121,

    "videooven.com" : 3121,
    "www.videooven.com" : 3121,

    "searchingpath.com" : 3121,
    "www.searchingpath.com" : 3121,

    "ototouch.com" : 3121,
    "www.ototouch.com" : 3121,

    "newhills.com" : 3121,
    "www.newhills.com" : 3121,

    "kevinwhitman.com" : 3121,
    "www.kevinwhitman.com" : 3121,

    "kevinthenerd.com" : 3121,
    "www.kevinthenerd.com" : 3121,

    "kevinthen3rd.com" : 3121,
    "www.kevinthen3rd.com" : 3121
}

is my routes.json if that's any helpful.

keverw commented Jul 1, 2012

Any ideas how to fix this? Or is it a bug?

bancek commented Jul 9, 2012

I've had similar bug. This code fixed it:
bancek/bouncy@da50b1e

keverw commented Jul 9, 2012

Thank's bancek. For now I switched back to using Apache. but if I do create a node.js base app, I'll try that I think. I just wanted the option to host both in the future, when I do create a node.js app that I want to make public.

I'm getting the same issue now. I never used to before, but now on occasion bouncy crashes sending error reports like:

Error: write EPIPE
    at errnoException (net.js:904:11)
    at Object.afterWrite (net.js:720:19)

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: read ECONNRESET
    at errnoException (net.js:904:11)
    at TCP.onread (net.js:558:19)

These aren't very helpful. Here's my code:

var fs = require('fs');
var crypto = require('crypto');
var bouncy = require('bouncy');

var domains = {
    // Default
    "": 8000,

    'xxxxxxxxxx.com': {
        port: 8000,
        key: fs.readFileSync('/apps/xxxxxxxxxx/server.key.pem', 'utf8'),
        cert: fs.readFileSync('/apps/xxxxxxxxxx/server.cert.pem', 'utf8'),
        passphrase: "Wrsoqwik2poO3fio"
    },
    "www.xxxxxxxxxx.com": {
        port: 8000,
        key: fs.readFileSync('/apps/xxxxxxxxxx/server.key.pem', 'utf8'),
        cert: fs.readFileSync('/apps/xxxxxxxxxx/server.cert.pem', 'utf8')
    },
    "dev.xxxxxxxxxx.com": 8023,
    "vogue.xxxxxxxxxx.com": 8003,
    "past.xxxxxxxxxx.com": 8004,
    "insecure.xxxxxxxxxx.com": {
        port: 8000
    },

    "m.xxxxxxxxxx.com": {
        port: 8002,
        key: fs.readFileSync('/apps/xxxxxxxxxx/server.key.pem', 'utf8'),
        cert: fs.readFileSync('/apps/xxxxxxxxxx/server.cert.pem', 'utf8')
    },

    "xxxxxxxxxxxxx.in": 8100,
    "www.xxxxxxxxxxxxx.in": 8100,

    "xxxxx.com": 8050,
    "www.xxxxx.com": 8050,

    "xxx.com": 8150,
    "www.xxx.com": 8150,

    "xxxxxxxxxxxxxxxx.com": 8200,
    "www.xxxxxxxxxxxxxxxx.com": 8200,

    "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx.com": 8300,
    "www.xxxxxxxxxxxxxxxxxxxxxxxxxxxxx.com": 8300,
    "xxxxxxxxxxxxxxxxx.com": 8300,
    "www.xxxxxxxxxxxxxxxxx.com": 8300
}

function sniCheck(domainname) {
    if (~Object.keys(domains).indexOf(domainname)) {
        var domain = domains[domainname];


        if (typeof domain === 'object' && domain.port && domain.key && domain.cert)
        {
            var cry = crypto.createCredentials({
                key: domain.key,
                cert: domain.cert,
                passphrase: domain.passphrase
            })

            return cry.context;
        }
    }
}

// HTTPS

bouncy({
        // key: fs.readFileSync('/apps/bouncer/selfsigned.key.pem', 'utf8'),
        // cert: fs.readFileSync('/apps/bouncer/selfsigned.cert.pem', 'utf8'),
        key: fs.readFileSync('/apps/bouncer/xxxxxxxxxx.key.pem', 'utf8'),
        cert: fs.readFileSync('/apps/bouncer/xxxxxxxxxx.cert.pem', 'utf8'),
        SNICallback: sniCheck
    },
    function (req, bounce) {
        var domain = domains[req.headers.host];
        var port = typeof domain === 'object' 
            ? domain.port
            : typeof domain === 'number'
                ? domain
                : domains[""];

        bounce(port);
    })
    .listen(443);

// HTTP

bouncy(function(req, bounce){
    var domain = domains[req.headers.host];
    var port = typeof domain === 'object' 
        ? domain.port
        : typeof domain === 'number'
            ? domain
            : domains[""];

    try {
        if (domain.key && domain.port)
        {
            var res = bounce.respond();
            res.statusCode = 302;
            res.setHeader("Location", "https://"+req.headers.host+req.url);
            res.end();
            return;
        }

        bounce(port);
    }
    catch (err)
    {
        console.log("Domain "+req.headers.host+" not found in routes config.");
    }
}).listen(80)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment