I have seen some post on this forum regarding Socket.IO and node.js. But still isn't working optimally.
port 80 and port 8080 are used by my webserver for different applications. So in App.js and my socket connection I added port 8081 instead of 8080.
I'm getting the websocket connection invalid message. After 10 seconds or so it has created the websocket and i'm able to use it perfectly well.
But 10 seconds is a too long. Any ideas how to fix this?
script.js:
<script>
var socket = io.connect('http://domainname.nl:8081');
socket.on('connect', function(){
socket.emit('adduser', "<?php echo $user->first_name; ?>");
});
app.js
var app = require('express').createServer()
var io = require('socket.io').listen(8081);
app.listen(8081);
// routing
app.get('/', function (req, res) {
res.sendfile(__dirname + '/index.html');
});
UPDATE:
When I have changed it. I still got the problem. The sockets works but takes 10 seconds to get connected
info - socket.io started
debug - served static /socket.io.js
debug - client authorized
info - handshake authorized 15619940591959058675
debug - setting request GET /socket.io/1/websocket/15619940591959058675
debug - set heartbeat interval for client 15619940591959058675
warn - websocket connection invalid
info - transport end
debug - set close timeout for client 15619940591959058675
debug - cleared close timeout for client 15619940591959058675
debug - cleared heartbeat interval for client 15619940591959058675
debug - client authorized for
debug - setting request GET /socket.io/1/xhr-polling/15619940591959058675?t=1345479037596
debug - setting poll timeout
debug - clearing poll timeout