Skip to content

Commit

Permalink
Fixed #13, eventually crash when elasticsearch connection error
Browse files Browse the repository at this point in the history
  • Loading branch information
Felix committed Mar 10, 2014
1 parent 8ae4b66 commit 49fb099
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/es-proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ function proxyRequest(request, response, host, port, user, password, getProxiedR

var proxyReq = http.request(options);

proxyReq.addListener('error', function(err){
response.status(500).send('Unable to process your request, ' + err.code);
console.log('ElasticSearch Server Error: ' + err.code);
});

proxyReq.addListener('response', function(proxyResp) {
var http10 = request.httpVersionMajor === 1 && request.httpVersionMinor < 1;
if(http10 && proxyResp.headers['transfer-encoding'] !== undefined){
Expand Down

0 comments on commit 49fb099

Please sign in to comment.