0

So I'm currently moving a Node.js application from my local computer to a production server. Socket.IO (version 0.6.17) seems to work fine on my server, but the client errors out when trying to communicate to the server.

Here's some code:

<script src='http://cdn.socket.io/stable/socket.io.js'>
    // ...
    var socket = new io.Socket(null, { port: 47556 }).connect();
    // ...
</script>

And here's what Google Chrome's console outputs after every few seconds (continuously):

GET http://mysite.com:47556/socket.io/xhr-polling//1304476733618 undefined (undefined)

Someone mentioned that it may be due to a version difference between the client and socket.io versions, but I don't know how I'd check the client side version.

1
  • 1
    If you can't reach mysite.com:47556 from client, could your web hosting company be blocking it? Can you access that port from your server? Commented May 5, 2011 at 15:33

2 Answers 2

3

To be safe, I would use the socket.io client script distributed with the server. Change your script tag to reference "/socket.io/socket.io.js" (I think) and let your app serve it. This will also Flash Sockets work without having to put it in insecure mode (because of the cross-domain issue).

Sign up to request clarification or add additional context in comments.

3 Comments

The file exists and I used it, but I'm still having the same issues. Any more ideas?
Same behavior in other browsers? Sure the port number is correct?
The stylesheet will atleast load in Safari and Firefox, but other than that I'm getting the same error in Firebug. Also, I set this up on Webfaction's hosting, and I'm using the assigned port of 47556.
0

Turns out the problem was that WebSockets don't send normal HTTP requests, resulting in their getting trashed by nginx. From a Q/A discussion with my hosting company, they said the solution would be to buy a private IP which would be specially used to listen for WebSocket connections.

I ended up going with Nodester to host my Node.js app, though.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.