Quantcast
Channel: Active questions tagged https - Stack Overflow
Viewing all articles
Browse latest Browse all 1854

How to stop a random node error: '(node:196569) Warning: An error event has already been emitted on the socket.'

$
0
0

I have an express web server built in node.js. When I run my server, eventually I get the following error in the terminal:

(node:196569) Warning: An error event has already been emitted on the socket. Please use the destroy method on the socket while handling a 'clientError' event.(Use `node --trace-warnings ...` to show where the warning was created)

I am using node:https to create the server as follows:

const express = require('express');const https = require('node:https');// setting up expressconst app = express();// Setting up SSL Certificatesconst https_options = {    key: process.env.HUTCHYBOP_KEY.replace(/\\n/g, '\n'),    cert: process.env.CRT_CODE.replace(/\\n/g, '\n'),    keepAlive: false};... rest of my code, routes ect...// http server (Port 80, should redirect to https);app.listen(80);// https Server (Port 443)https.createServer(https_options, app).listen(443, () => {    console.log('Server listening on PORT 443 (https)');    serveHTTP() // logging function});

After doing some reading, I added the keepAlive option hoping it might solve the issue, it did not.

I have added the --trace-warnings option and got:

(node:230020) Warning: An error event has already been emitted on the socket. Please use the destroy method on the socket while handling a 'clientError' event.    at warnUnclosedSocket (node:_http_server:827:11)    at TLSSocket.socketOnError (node:_http_server:841:5)    at onParserExecuteCommon (node:_http_server:876:19)    at onParserExecute (node:_http_server:797:3)

I have had a google round for solutions to the error but have come up short and I'm fairly new to this so I'm now stuggling to work out what to do next.

Does anybody know why the error is happing and how to stop it?


Viewing all articles
Browse latest Browse all 1854

Trending Articles