So I've made a multiplayer space shooter using node.js, socket.io and kineticJS. My Node.js server does not actually serve the client's page. My client-side files are currently hosted in a local Apache server on my computer.
The node server is up and running on Heroku right now and I can't seem to be able to get socket.io loaded on the client-side. I keep getting the "io is not defined" error. This is how I import the script:
<script src="http://xxx-xxx-xxxx.herokuapp.com:5000/socket.io/socket.io.js"></script>
I have followed the instructions shown here: https://devcenter.heroku.com/articles/nodejs And my package.json file looks like this:
{
"name": "Grid-Frontier",
"version": "0.0.1",
"dependencies": {
"socket.io": "0.9.x"
},
"engines": {
"node": "0.6.x"
}
}
On localhost everything is fine and I can just do the following:
// Importing on client side
<script src="http://localhost:8080/socket.io/socket.io.js"></script>
// Server-side
server.listen(8080);
socket = io.listen(server);
Because Heroku allows you only to communicate in port 80, you cannot use other ports therefore the address should be: http://xxx-xxx-xxxx.herokuapp.com/socket.io/socket.io.js
not port 5000. Actually there is nothing on port 5000, it is internal to machine.