ruby-on-railsubuntusocket.iojuggernaut

Rails 3.1 working with Socket.io/Juggernaut on Ubuntu 11.10


I couldn't get Juggernaut/Socket.IO running on Windows so I took a shot at getting it running on Linux. I don't know much Linux (or Rails for that matter). I can't get Socket.io/Juggernaut working on my Rails server. It works OK on OS X (so I know it's working).

After everything installed, I do the following:

/rails/app/path/rails s
redis-server
juggernaut # output is: info  - socket.io started

So I'm guessing that works OK. Now, when I run a window that uses Juggernaut, I get the following error in the Chrome Javascript Console:

XMLHttpRequest cannot load http://localhost:8080/socket.io/xhr-polling//1322359666443. Origin http://localhost:3000 is not allowed by Access-Control-Allow-Origin.
Resource interpreted as Script but transferred with MIME type text/plain.
Uncaught SyntaxError: Unexpected identifier

Software information:


Solution

  • This looks like a CORS issue, where the browser won't allow an AJAX request to another origin (in this case port 8080).

    You might need to set your CORS headers in Socket.IO.

    I found this answer: https://stackoverflow.com/a/10423354/351937

    To find out more about CORS, have a look here: http://enable-cors.org/ and Google of course.