use socket.io on other port

node.js, php, socket.io

Solution

I'm new to `socket.io` and so far I really like what I'm seeing.

I just wanted to point out a small correction to @sdedelbrock's post.

You probably should not use (as was recommended):

<script src="/socket.io/socket.io.js"></script>
<script>
  var socket = io.connect('http://localhost:4040');
</script>

Since this will assume the server is also on the same machine (use of `localhost`). This is what some of my DEV's did and when I deployed their code, it wasn't working at all (client page could not find our server).

What I've tried, and it seems to work well, is to let the `host` portion be auto-resolved by the XHR, by ONLY providing the port number.

Use the following instead:

<script src="/socket.io/socket.io.js"></script>
<script>
  var socket = io.connect(':4040');
</script>

So no matter to which environment I deploy to (ie: DEV, TEST, STAGE or PROD, etc.) it will always resolve the proper host name client side. Which is what we want.

Problem

I'm trying to make chat based on NodeJS and Socket.IO All the work is good when I run it on the same port 4040 but when I put the source code of socket.io on other port it doesnt work on ie6 and on ie7 & 8 I see the page refreshed every time when get new data shortly, I have a website based on PHP port 80, I made chat based on nodeJs port 4040 website work fine and the chat also work fine on port 4040 this is the source of socket.io work fine on port 4040 : ``` <script src="/socket.io/socket.io.js"></script> ``` work but with problemes on ie 6 7 8 ``` <script src="http://mywebsite.com:4040/socket.io/socket.io.js"></script> ``` please don't downgrade my question because I know many of you don't understand 100% my question

Original source