Skip to content

Commit 49fb099

Browse files
author
Felix
committed
Fixed #13, eventually crash when elasticsearch connection error
1 parent 8ae4b66 commit 49fb099

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

lib/es-proxy.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ function proxyRequest(request, response, host, port, user, password, getProxiedR
3737

3838
var proxyReq = http.request(options);
3939

40+
proxyReq.addListener('error', function(err){
41+
response.status(500).send('Unable to process your request, ' + err.code);
42+
console.log('ElasticSearch Server Error: ' + err.code);
43+
});
44+
4045
proxyReq.addListener('response', function(proxyResp) {
4146
var http10 = request.httpVersionMajor === 1 && request.httpVersionMinor < 1;
4247
if(http10 && proxyResp.headers['transfer-encoding'] !== undefined){

0 commit comments

Comments
 (0)