Socket.IO issue with illegal origin?

I am using : "socket.io": "~0.9.10"

I am running into this issue when I go to my apache webserver hosted client.html page hosted on port 80:

XMLHttpRequest cannot load http://localhost:5000/socket.io/1/?t=1348624895534. Origin http://localhost is not allowed by Access-Control-Allow-Origin.

I am running SocketIO on my serverside to be on port 5000 as shown below:

io = io.listen(5000);
io.set("origins","*");

However, everytime I load my apache client.html page, I see in my SocketIO server console:

warn: illegal origin: http://localhost

How do I get rid of this issue?

You are doing CORS.

The error you are getting comes from the fact that Socket.IO seems to be using XHR rather that Websockets. This is what socket.IO does when websockets are not available it uses another protocol, FlashSockets, XHR-polling... etc.

You need to set a header on you apache server to allow a query to be made to another website, here your Socket.io server.

Here is a how to.

It would be a lot simpler for you if you just used only one server. You could use Express to deliver the static html file. Here is a demo/tutorial app to get started easily with Socket.IO + Express.

This demo is a boiler plate to push on dotCloud, so if you want to painlessly deploy, follow those instructions.

Try setting 'Access-Control-Allow-Origin' header to '*'

response.writeHead(200, {
  'Access-Control-Allow-Origin': '*'
});