Kwang Kwang - 3 months ago 23
Node.js Question

Socket.io keeps reconnecting, even i don't use socket.io now

I've run the chatting server and delete it.

So, I don't have any file which uses socket.io

'use strict'
const
express = require('express')
,mongoose = require('mongoose')
,logger = require('morgan')

const
app = express()


// === db setting ===



// === initial setting ===
app.set('view engine', 'pug');
app.set('views', './views');
app.use(express.static('public'));


// === 3rd party middlewares ===
app.use(logger('dev'));


// === router ===
app.get('/', (req, res, next) => {
res.send('hello world');
});


// === error handler ===


// === server running ===
app.listen(8000, () => {
console.log('=== server is running ===');
});


However when i run the new server, it keeps showing me this message below.

How can i fix this?

enter image description here

Answer

This shows that you have some socket.io client code in front-end code somewhere (e.g. some web page attempting to use your server) that is trying to connect to to your server using socket.io but failing.

To stop this from happening, you need to remove the socket.io code from your web page.

Probably there is a line of code in your web page somewhere that looks like this:

var socket = io();

Remove that from the web page (and other references to socket.io).