Socket.io xhr fallback cross domain issue

Front Page Forums Development Socket.io xhr fallback cross domain issue

This topic contains 5 replies, has 1 voice, and was last updated by  James 4 months, 2 weeks ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #5178 Reply

    Caner

    Hi to everyone,

    I just want to state a technical issue just realized when trying publisher script. May be you already know then never mind 🙂
    Sometimes socket.io can fallback to xhr long polling instead of websocket because of poor connection I think. In this case browser blocks xhr requests because of cross origin request policy so can not send any data. I think you should configure websocket server side in order to response with suitable cross origin http headers.

    Cool project by the way. Congrats team

    #5182 Reply

    James

    Hi Caner,

    This was not something I was aware of. I’ll try and get a fix rolled out before the weekend. Think the options are to try and set access-control headers without causing a security leak or just force websockets if this isn’t possible. There’s an interesting thread here: https://stackoverflow.com/questions/8970880/cross-domain-connection-in-socket-io

    Will need to do some testing and replicate this in a dev environment.

    Thanks for sending this in.

    #5184 Reply

    glemiere

    Bwark I’ve had this issue by the past on an early stage version of socket.io. Don’t remember how I fixed it, I remember it was painful though.
    Good luck!

    #5221 Reply

    James

    I think this should be solved now. It’s a CORS issue with socket.io which wasn’t taking notice of the response headers set in the express app routes.

    Additionally we are loading the socket.io.js file from a 3rd party CDN which might have been adding to the problem.

    Anyway we’ve rolled out an update this evening and I’m hoping this should fix the issue although it’s not something we have been able to replicate here so hard to tell for sure. Let me know if you get any further errors.

    #5253 Reply

    Caner

    Ok I have done a quick check by editing socket connection script a bit and it looks like the problem solved.
    I checked socket.io docs, this is how i replicate and force only xhr polling:

    var socket = io.connect(jseLoadServer, {transports: [‘polling’]});

    by this way socket.io only uses xhr instead of websocket. And it is working now without errors.

    #5255 Reply

    James

    Thank you Caner, we had another issue with XHR polling giving an SSL error. We’ve tried forcing secure connections on an update which was rolled out about four hours ago which I’m hoping will put the socketio polling issues behind us.

Viewing 6 posts - 1 through 6 (of 6 total)
Reply To: Socket.io xhr fallback cross domain issue
Your information: