Giter Site home page Giter Site logo

Comments (5)

aaugustin avatar aaugustin commented on September 7, 2024 1

I don't know enough about iOS development to document what you explained in the FAQ (and it's a bit out of scope of what I'm willing to document.) Hopefully other users hitting the same problem with websockets will find this issue and it will put them on the right track.

from websockets.

aaugustin avatar aaugustin commented on September 7, 2024

Your don't need to send a Connection: upgrade header — websockets does that.

    header = {
        'Connection' : 'upgrade',
        'Access-Control-Allow-Origin' : '*'
        }

Maybe iOS dislikes the duplicate header?

from websockets.

WORMSTweaker avatar WORMSTweaker commented on September 7, 2024

Ah indeed, I didn't notice that was the case, so I added it myself to try and see if it helped. So removing the duplicate header seems to have changed something, on the Python side, the server indicates a DEBUG = connection is CONNECTING, on the JS side though onerror is triggered followed by the onclose event, no message received, no message sent:

image

So some progress? At least python-websockets isn't exploding anymore, but now why is iOS closing the connection prematurely?

from websockets.

WORMSTweaker avatar WORMSTweaker commented on September 7, 2024

Update, and really I'm baffled by how to fix this, and if somebody has an explanation of why this is how things are done on iOS, please enlighten us all.

So, turns out, iOS HATES when your websockets are not opened in an asynchronous manner, so, the simple fix for websockets not opening is to define an async function, and await for the websocket to open, which on paper sounds logical, but I haven't found a single ounce of documentation about this.

I tested this on my previous simple echo example, works perfectly, tested on my bigger project, works too, so I suppose the case is closed. I don't know if you want to add more to this since it's not a python-websockets related issue at this point.

from websockets.

aaugustin avatar aaugustin commented on September 7, 2024

Apple doesn't really want to you keep long-lived TCP connection. They'd rather you use APNS.

from websockets.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.