Comments (5)
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.
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.
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:
So some progress? At least python-websockets isn't exploding anymore, but now why is iOS closing the connection prematurely?
from websockets.
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.
Apple doesn't really want to you keep long-lived TCP connection. They'd rather you use APNS.
from websockets.
Related Issues (20)
- Cannot Send message to a single client.
- handling multiple websocket client connections HOT 4
- Enable to connect ! invalid handshake HOT 7
- recv() is slow HOT 5
- Client state is incorrect HOT 1
- Feature batch receive HOT 2
- [QUESTION] Switching from websocket-client to websockets HOT 1
- Sync version of broadcast HOT 2
- Running Scheduled Task in Websokcets Or Scaling with multiple workers HOT 1
- await websocket.recv() block the coroutine loop. HOT 1
- When using websockets as a client, how to send a pong when receiving a ping? HOT 1
- Make MAX_LINE configurable HOT 5
- When I use websocket to transmit continuous audio pcm data to the server, half of the data is lost HOT 1
- websocket over stomp received Session closed error HOT 5
- Connection breaks in between during a sustained transfer HOT 9
- When there are N channels in a group, sending a message to the group will be sent N times HOT 1
- Asking for Guidance in Writing a WebsocketHandler for the Python logging Module HOT 3
- question: intended behavior with failed auth and async for auto-reconnect HOT 28
- Clean up tests on PyPy HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from websockets.