3

I have a web application. Its backend is by nodejs, and runs with pm2 and nginx.

When I do sudo pm2 logs in the server, I see the following error keeps rolling out constantly, though the main features of the application don't seem to be disturbed.

0|npm  | index.js router.get *
0|npm  | kpi.js POST /socket.io/?EIO=3&transport=polling&t=OXijmvI
0|npm  | index.js POST /socket.io/?EIO=3&transport=polling&t=OXijmvI
0|npm  | Error: Not Found
0|npm  |     at /opt/funpro/app.js:122:13
0|npm  |     at Layer.handle [as handle_request] (/opt/funpro/node_modules/express/lib/router/layer.js:95:5)
0|npm  |     at trim_prefix (/opt/funpro/node_modules/express/lib/router/index.js:317:13)
0|npm  |     at /opt/funpro/node_modules/express/lib/router/index.js:284:7
0|npm  |     at Function.process_params (/opt/funpro/node_modules/express/lib/router/index.js:335:12)
0|npm  |     at next (/opt/funpro/node_modules/express/lib/router/index.js:275:10)
0|npm  |     at /opt/funpro/node_modules/express/lib/router/index.js:635:15
0|npm  |     at next (/opt/funpro/node_modules/express/lib/router/index.js:260:14)
0|npm  |     at /opt/funpro/routes/index.js:23:2
0|npm  |     at Layer.handle [as handle_request] (/opt/funpro/node_modules/express/lib/router/layer.js:95:5)
0|npm  |     at trim_prefix (/opt/funpro/node_modules/express/lib/router/index.js:317:13)
0|npm  |     at /opt/funpro/node_modules/express/lib/router/index.js:284:7
0|npm  |     at Function.process_params (/opt/funpro/node_modules/express/lib/router/index.js:335:12)
0|npm  |     at next (/opt/funpro/node_modules/express/lib/router/index.js:275:10)
0|npm  |     at Function.handle (/opt/funpro/node_modules/express/lib/router/index.js:174:3)
0|npm  |     at router (/opt/funpro/node_modules/express/lib/router/index.js:47:12)
0|npm  |     at Layer.handle [as handle_request] (/opt/funpro/node_modules/express/lib/router/layer.js:95:5)
0|npm  |     at trim_prefix (/opt/funpro/node_modules/express/lib/router/index.js:317:13)
0|npm  |     at /opt/funpro/node_modules/express/lib/router/index.js:284:7
0|npm  |     at Function.process_params (/opt/funpro/node_modules/express/lib/router/index.js:335:12)
0|npm  |     at next (/opt/funpro/node_modules/express/lib/router/index.js:275:10)
0|npm  |     at /opt/funpro/node_modules/express/lib/router/index.js:635:15

/opt/funpro/app.js:122:13 starts here:

// catch 404 and forward to error handler
app.use(function (req, res, next) {
  var err = new Error('Not Found');
  err.status = 404;
  next(err);
});

If I search socket.io in the code base, I can see some, but I totally forgot why we used it and how to use it.

Does anyone know what the error is about and how to remove it?

SoftTimur
  • 5,630
  • 38
  • 140
  • 292

1 Answers1

2

Socket.io is not receiving the requests, so express falls back to your error handler, resulting in the error. If socket.io is not used in the frontend you can simply remove it.

If you require socket.io for the app, you can follow the instructions in this answer to link it up with express, which should allow it to receive its requests.

amycodes
  • 902
  • 14