- this.authenticate(req, (err) => {
- if (err) {
- socket.write(`HTTP/1.1 ${StatusCodes.UNAUTHORIZED} Unauthorized\r\n\r\n`);
- socket.destroy();
- return;
+ const onSocketError = (error: Error): void => {
+ logger.error(
+ `${this.logPrefix(
+ moduleName,
+ 'start.httpServer.on.upgrade'
+ )} Socket error at connection upgrade event handling:`,
+ error
+ )
+ }
+ socket.on('error', onSocketError)
+ this.authenticate(req, err => {
+ if (err != null) {
+ socket.write(`HTTP/1.1 ${StatusCodes.UNAUTHORIZED} Unauthorized\r\n\r\n`)
+ socket.destroy()
+ return