I am finding it hard to connect to socket and I don't know what I am doing wrong This is the entry point:
const { PORT } = process.env;
const server = http.createServer(this.app);
const io = new SocketServer(server);
io.startSever();
server.listen(PORT || this.port, () => {
console.log(`App listening on the port ${this.port}`);
});
import { Server } from 'socket.io';
class SocketServer {
public io;
constructor(server: any) {
this.io = new Server(server, {
cors: {
origin: '*',
},
});
// console.log(this.io);
}
startSever() {
this.io.on('connect_error', (err) => {
console.log(`connect_error due to ${err.message}`);
});
this.io.on('connection', (socket) => {
console.log('Socket connected successfully');
});
}
}
export default SocketServer;
It is not listening for the on connection so the logging never happens