Beginner to socket io. Need help with connection #4452
Unanswered
Naveenravi07
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
hi i am creating a classmanagement system with socket io . i need help with the connection . I am using expressjs as backend .
in my routes folder i have a file named index.js and this is how it looks like
var express = require('express');
var router = express.Router();
const app = require("../app");
var http = require("http").Server(app);
var io = require("socket.io")(http);
/* GET home page. */
io.on('connection', socket => {
console.log("new connection");
})
router.get('/', function (req, res, next) {
res.render('index');
});
router.get('/createclass', (req, res) => {
})
module.exports = router;
in the rendering of this route i have a file named index.hbs where i configured the client side of socket io
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/4.5.1/socket.io.js"></script>
<script type="text/javascript"> let socket=io() socket.on('connect',()=>{ console.log("connected newwwwwwwwww") }) </script>### some contentwhen i visit my localhost mainroute the browser console always shows me this error in each 5 seconds .

Beta Was this translation helpful? Give feedback.
All reactions