Skip to content
This repository has been archived by the owner on Sep 25, 2020. It is now read-only.

Catching handleOrProxy errors when request is sent to node that has failed. #303

Open
sashahilton00 opened this issue Aug 16, 2016 · 0 comments

Comments

@sashahilton00
Copy link
Contributor

When testing Ringpop in a small cluster, I have been testing how ringpop handles node failures. When a node goes down, and a request is handleOrProxy()'d, there is a period of approximately 5 seconds where ringpop continues to forward requests to the dead node. Whilst this is expected, it throws a rather ugly error response: tchannel socket error (ECONNREFUSED from connect): connect ECONNREFUSED 10.2.0.17:9880. Is there any way that an extra argument could be added to the handleOrProxy() method that would be called when such an error occurs so that we can send a formatted response that our application can read? eg. handleOrProxy(req, res, errCallback) where errCallback is something like the example below:

function errCallback (err, req, res) {
    switch (err) {
        case 'ECONNREFUSED':
        res.end(JSON.stringify({status: 'failed', error: 'connection_refused', message: 'Could not connect to the correct server.', retry_in: 5}));
        break;

        case 'ETIMEDOUT':
        res.end(JSON.stringify({status: 'failed', error: 'connection_timeout', message: 'The connection timed out.', retry_in: 20}));
        break;

        //etc.
    }
}
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant