jpillora / xdomain

A pure JavaScript CORS alternative
https://jpillora.com/xdomain/
3.13k stars 270 forks source link

socket.io xdomain error #78

Closed throrin19 closed 10 years ago

throrin19 commented 10 years ago

Hello, in my project i have a problem with socket.io and your library.

If i activate socket.io, xdomain crash with the Access Denied error and the 'no slave matching'.

If i remove socket.io, i have no problem.

Have you an idea of my problem ?

jpillora commented 10 years ago

have you looked at https://github.com/jpillora/xdomain#faq--troubleshooting ? is there a demo running anywhere?

throrin19 commented 10 years ago

Yes. It works fine if i don't try to connect on socket.io.

This is my config :

client side :

<!DOCTYPE html>
<head>
 ...
    <!--[if lte IE 10]>
    <script type="text/javascript" src="js/libs/vendors/xdomain/dist/0.6/xdomain.min.js" slave="http://api.foo.com/v1.1/proxy"></script>
    <script type="text/javascript">
        xdomain.debug = true;
    </script>
    <![endif]-->
</head>
<body>
</body>
</html>

server side on /v1.1/proxy :

<!doctype html>
<html>
<head>
    <meta charset="UTF-8">
    <title></title>
    <script src="js/libs/vendors/xdomain.min.js" master="http://client.foo.com"></script>
</head>
<body>
</body>
</html>

Client and server side are differents.

this is my expressJS CORS configuration for headers :

var corsOptions = {
            methods: ["GET", "POST", "PUT", "DELETE", "OPTIONS", "PATCH"],
            origin : true
            //credentials: true,
            //allowedHeaders : "X-CSRF-Token, X-Requested-With, Origin, Accept, Accept-Encoding, Accept-Version, Content-Length, Content-MD5, Content-Type, evt-id, api-key, del-all, mod-id"
        };
    this.use(cors(corsOptions));
jpillora commented 10 years ago

under IE, does socketio use flash for websockets? what about cross-domain websockets? xdomain only replaces XMLHttpRequest

xdomain doesn't use CORS in anyway, it implements CORS-like functionality with an alternate method

since im not sure what socketio is doing, im not sure where its going wrong

On Thu, May 22, 2014 at 11:58 PM, Benjamin Besse notifications@github.comwrote:

Yes. It works fine if i don't try to connect on socket.io. I have this problem only if i use socket.io. I don't understand the bug.

This is my config :

client side :

<!DOCTYPE html> ...

server side on /v1.1/proxy : Client and server side are differents. this is my expressJS CORS configuration for headers : var corsOptions = { methods: ["GET", "POST", "PUT", "DELETE", "OPTIONS", "PATCH"], origin : true //credentials: true, //allowedHeaders : "X-CSRF-Token, X-Requested-With, Origin, Accept, Accept-Encoding, Accept-Version, Content-Length, Content-MD5, Content-Type, evt-id, api-key, del-all, mod-id" }; this.use(cors(corsOptions)); — Reply to this email directly or view it on GitHubhttps://github.com/jpillora/xdomain/issues/78#issuecomment-43891272 .
throrin19 commented 10 years ago

if user has noo flash player installed, socket.io passed by xhr-poll.

in the ie console (whith xdomain.debug = true and socket.io active) i have this :

Journal : xdomain (http://client.foo.com) no slave matching 'http://api.foo.com:80'
jpillora commented 10 years ago

Oh that :80 would be causing it mismatch, can you remove it from the URL?

On Friday, May 23, 2014, Benjamin Besse notifications@github.com wrote:

if user has noo flash player installed, socket.io passed by xhr-poll.

  • whithout xdomain.js, socket works but $.ajax does not works.
  • with xdomain, $.ajax works but socket.io does not works.

in the ie console (whith xdomain.debug = true and socket.io active) i have this :

Journal : xdomain (http://client.foo.com) no slave matching 'http://api.foo.com:80'

— Reply to this email directly or view it on GitHubhttps://github.com/jpillora/xdomain/issues/78#issuecomment-43893852 .

throrin19 commented 10 years ago

I do not know where it comes from. In the xdomain script i have this on slave :

http://api.foo.com/v1.1/proxy

It would be socket.io which would conflict? This is my client socket.io config :

App.current.socket = io.connect('http://api.foo.com', {
                'try multiple transports'       : false,
                'transports'                    : [
                    'websocket',
                    'flashsocket',
                    'htmlfile',
                    'xhr-polling',
                    'jsonp-polling'
                ]
            });
jpillora commented 10 years ago

Okay you could try adding the slave again, though add :80 to second one

On Friday, May 23, 2014, Benjamin Besse notifications@github.com wrote:

I do not know where it comes from. In the xdomain script i have this on slave :

http://api.foo.com/v1.1/proxy

It would be socket.io which would conflict? This is my client socket.ioconfig :

App.current.socket = io.connect('http://api.foo.com', { 'try multiple transports' : false, 'transports' : [ 'websocket', 'flashsocket', 'htmlfile', 'xhr-polling', 'jsonp-polling' ] });

— Reply to this email directly or view it on GitHubhttps://github.com/jpillora/xdomain/issues/78#issuecomment-43896848 .

throrin19 commented 10 years ago

it works fine. thanks for your job ;)