Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

{ [Error: socket hang up] code: 'ECONNRESET' } #395

Closed
gahula opened this Issue · 2 comments

2 participants

@gahula

Trying to interact with a server running on a sub-domain and I receive { [Error: socket hang up] code: 'ECONNRESET' }

@mikeal
Owner

wherever you do request() you'll want to do something like var r = request(); r.on('error', function (err){}) so that you can tell where you're getting the error and keep it from throwing.

this means the socket disconnected in a client request.

@mikeal mikeal closed this
@gahula

The below code works on my localhost. now i get { [Error: socket hang up] code: 'ECONNRESET' }
doesn't event seem it is making the request to the sub-domain. It just hangs up.
.
**The code is used to send files received via ajax and forward them to a sub domain

options.method = 'POST';
options.url = 'http://sub.domain.com/username';

var request = cdn(options, function(error, response, body) {
    if(error) {
        console.log(error);
        res.send(500);
    }
    else{
        if(response) {
            res.headers = response.headers;
        }
        if(body) {
            res.send(response.statusCode, body);
        }
    }
});

var form = request.form();

_.each(req.files.files, function (file) {
    var i = file.name.lastIndexOf('.');
    var ext = file.name.substr(i);
    var path = file.path + ext;
    var error = validate(file, ext);
    if(error) {
        console.log(error);
        res.send(500);
    } else {
        form.append(ext, fs.createReadStream(file.path)); server
    }
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.