Skip to content

Commit 40757a2

Browse files
Adding socket hangup logs
1 parent 1edcf05 commit 40757a2

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

lib/config/constants.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ const RECONNECT_ID_HEADER = 'x-reconnect-id';
4848

4949
const OUTGOING = '[OUTGOING]';
5050
const INCOMING = '[INCOMING]';
51+
const HTTPLOG = '[HTTP]';
5152

5253
class ConfigParser {
5354
setRetries() {
@@ -253,4 +254,5 @@ module.exports = {
253254
kUpstreamRestart,
254255
PROXY_LOCKED,
255256
PROXY_RESTART,
257+
HTTPLOG
256258
};

lib/core/Proxy.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

33
const WebSocket = require('ws');
4-
const { config, kCleanup, kAddNewContext } = require('../config/constants');
4+
const { config, kCleanup, kAddNewContext, HTTPLOG } = require('../config/constants');
55
const logger = require('../util/loggerFactory');
66
const Context = require('./Context');
77
const {
@@ -63,13 +63,22 @@ class Proxy {
6363
method: request.method,
6464
headers: request.headers,
6565
};
66+
logger.info(`${HTTPLOG} Received http request ${options}`);
6667
const proxyReq = http.request(options, (proxyResponse) => {
6768
response.writeHead(proxyResponse.statusCode, proxyResponse.headers);
6869
proxyResponse.pipe(response, {
6970
end: true,
7071
});
7172
});
72-
73+
proxyReq.on('error', (error)=>{
74+
logger.error(`${request.url} received error ${error}`);
75+
});
76+
proxyReq.on('timeout', ()=>{
77+
logger.info(`${request.url} timed out`);
78+
});
79+
proxyReq.on('drain', ()=>{
80+
logger.info(`${request.url} drained out`);
81+
});
7382
request.pipe(proxyReq, {
7483
end: true,
7584
});

0 commit comments

Comments
 (0)