socket.io icon indicating copy to clipboard operation
socket.io copied to clipboard

"?disconnect=1" response has no allow-origin

Open tarikozket opened this issue 13 years ago • 6 comments

Using socket.io with subdomain like "socket.mydomain.com" and client configured sync disconnect on unload to true. and server origins configured to ":"

when I press the refresh button after connection establish, that log appears on console:

XMLHttpRequest cannot load http://socket.mydomain.com:443/socket.io/1//1AMbT-zUoTlrJ1tiw-0H/?disconnect=1. Origin http://mydomain.com is not allowed by Access-Control-Allow-Origin. Uncaught Error: NETWORK_ERR: XMLHttpRequest Exception 101

socket.io version : 0.9.11 nodejs version : 0.10.4

tarikozket avatar Apr 12 '13 11:04 tarikozket

Hi, I experience the same problem with node 0.8.14 and socket.io 0.9.13. However, it doesn't occur if I downgrade socket.io to 0.9.6.

farnoux avatar Apr 25 '13 14:04 farnoux

I have no idea about the real fix, but I changed line 1860 in version 0.9.16 from

xhr.open('GET', uri, false);

to

xhr.open('GET', uri, true);

error went away and disconnect is called.

Luoti avatar Aug 09 '13 11:08 Luoti

Because you turned on async method. So, request is still not receiving by server.

http://www.w3.org/TR/XMLHttpRequest/#the-open()-method

:/

tarikozket avatar Aug 09 '13 12:08 tarikozket

Hi folks Any further info/developments on this issue? I'm experiencing the same, using express.io, which in turn uses 0.9.16 of socket.io. Client and server are running on entirely different domains, as such, have enabled { origins: '*:*' } on the server, as well as 'sync disconnect on unload' on the client. Still get the following error in the browser every time

XMLHttpRequest cannot load https://my-socket-domain.herokuapp/socket.io/1//i01bsbcdiy-s_e-4YFsB/?disconnect=1
No 'Access-Control-Allow-Origin' header is present on the requested resource
Origin 'http://www.some-other-domain.com' is therefore not allowed access

This leaves open sockets idle on the server, which causes errors from the nginx proxy later on.

Happy to try and help look into this, if someone can just point me towards the right place in the source where the disconnect stuff occurs.

jazlalli avatar Feb 27 '14 11:02 jazlalli

+1

indrekj avatar Mar 20 '14 09:03 indrekj

+1

assisantunes avatar Mar 29 '14 23:03 assisantunes