socketio / socket.io

Realtime application framework (Node.JS server)
https://socket.io
MIT License
60.43k stars 10.08k forks source link

xhr-polling doesnt work on embedded webviews (phonegap, cordova) #1025

Closed max-mapper closed 11 years ago

max-mapper commented 11 years ago

if you restrict the transports (on both server and client settings) to ['websocket', 'xhr-polling'] then embedded webviews using socket.io won't be able to connect and will emit the connect_failed event

rauchg commented 11 years ago

Oh so setting secure: true still fails correct?

rauchg commented 11 years ago

If you can get me some more debugging information that would be great.

max-mapper commented 11 years ago

ok, turns out socket.io assumes that if window.location.href is not the same host as the host you pass into io.connect then it should skip xhr-polling. you can override this behavior by monkeypatching thusly:

io.Socket.prototype.isXDomain = function(){ return false; }
rauchg commented 11 years ago

* it assumes that only if CORS is not supported as well (io.util.ua.hasCORS needs to be false). Which is not on Android apparently, but WebViews still have the ability to disregard the origin security model. I'm introducing an option to solve this more elegantly without the override.