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

I could not get Juggernaut / Socket.IO to work on Windows, so I tried to run it on Linux. I don't know much Linux (or Rails, for that matter). I cannot get Socket.io/Juggernaut to work on my Rails server. It works fine on OS X (so I know it works).

After everything is installed, I do the following:

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

So, I assume that everything is working fine. Now, when I launch a window using Juggernaut, the following error appears 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:

  • Ubuntu 11.10
  • Ruby 1.9.2
  • Rails 3.1.1
  • NodeJS 0.4.9
  • NPM 0.2.19
  • Socket.IO v?.? (I just ran npm install socket.io today)
  • Juggernaut v?.? (I just ran npm install juggernaut today)
  • Tested in Firefox and Chrome
+4
source share
1 answer

This looks like a CORS problem where the browser does not allow the AJAX request to another source (in this case, port 8080).

You may need to set the CORS headers in Socket.IO.

I found this answer: fooobar.com/questions/774162 / ...

To learn more about CORS, look here: http://enable-cors.org/ and Google, of course.

0
source

Source: https://habr.com/ru/post/1383262/


All Articles