i am pretty new to Node.js . I am using socket.io to build up a real time feed application.
i am using http://socket.io/get-started/chat/ to get started with my application. in combination with express
Following is my server code
/**
* Module dependencies.
*/
var express = require('express');
var logger = require('morgan');
var routes = require('./routes');
var app = express();
var http = require('http').Server(app);
var io = require('socket.io')(http);
// log requests
app.use(logger('dev'));
app.use('/rest', routes.userInfo, routes.matchList, routes.teamList,
routes.completedMatchList);
io.on('connection', function(socket){
console.log('a user connected');
});
app.listen(3006);
console.log('listening on port 3006');
Then i have an index.html inside my web folder of my application.
I am just using plain code to intitalize the client socket as below
<script src="/node_modules/socket.io/node_modules/socket.io-client/socket.io.js"></script>
<script>
var socket = io();
</script>
I started my server and its work well But even after the client page loads and is served, connection event is not listened and the code is not printing in the console "user is connected".
Just to add a little bit, i use an application router in middle which starts at port 5000.
i checked in the chrome console, it is constantly reporting errors like
http://localhost:5000/socket.io/?EIO=3&transport=polling&t=LF2viiR
http://localhost:5000/socket.io/?EIO=3&transport=polling&t=LF2vj0v
Snapshot my chrome console with errors
cheers,
Saurav