Here is the set up of my dev server (with a valid domain. not just localhost)
Web server (by PHP Codeignitor)
/static/test.html
content of test.html:
<script src="http://dev.mydomain.com:8080/socket.io/socket.io.js></script>
<script>
io = io.connect('http://dev.mydomain.com:8080');
</script>
The socket server, by express.io:
app = express().http().io()
app.use(express.cookieParser())
app.use(express.session({secret:'xxx'}))
app.listen(8080)
When I run the node.js server and load http://dev.mydomin.com/test.html on the browser, it doesn't establish the socket connection. Because of handshake error from this file:
http://dev.mydomain.com:8080/socket.io/1/?t=1408568813150
handshake error
However, when I hit http://dev.mydomain.com:8080/WhateverPageNotExist on the browser, which hit a non-existing page from the node.js server, and come back to http://dev.mydomain.com:8080/socket.io/1/?t=1408568813150, it returns the hash code.. (which is right)
then I can load http://dev.mydomin.com/test.html without any problem with socket. i.e. once I hit the node.js server (on port 8080), then it will be ok for any page served by PHP server to establish the socket connection.
Why is like that? is there any way to solve this problem?