Comments (4)
I dug into this a bit more. There seem to be a couple issues doing on here:
- Suppose that client.fd receives 200 bytes. As long as no bytes have been read,
select(client.fd, [], timeout)
returns instantly. As soon as a byte has been read,select(client.fd, [], timeout)
takes timeout to return -- regardless of whether 1 or 200 bytes have been read. - Some browsers seem to send back-to-back empty messages, which all need to get read from the system. If empty messages are left unread, they seem to prevent PONG messages from being sent (I'm not sure in which direction), which causes the socket to timeout. I ended up with this implementation:
elif recv_event.is_set():
recv_event.clear()
try:
message = True
while message:
message = uwsgi.websocket_recv_nb()
recv_queue.put(message)
listening = spawn(listener, client)
except IOError:
client.connected = False
It ends up writing an empty message for every event, but better than the alternatives.
from flask-uwsgi-websocket.
That seems like a nice solution, would you like to send a PR?
from flask-uwsgi-websocket.
I will; it may be a couple days.
from flask-uwsgi-websocket.
Created #48
from flask-uwsgi-websocket.
Related Issues (20)
- feature request: non blocking receive
- Sending data as binary HOT 2
- Can I catch client disconnects on server-side? HOT 2
- Random error on init
- Asyncio "no PONG received in 3 seconds" after 30 seconds HOT 3
- How to run uwsgi-websocket behind Apache
- Add a changelog to the project
- websocket in flask + https HOT 1
- How can I fix this AsyncioWebSocket "RuntimeError: Event loop is closed" issue?
- Using request context with other decorators
- How to properly close a websocket
- Incompatibility with Python 3.7.0 HOT 3
- Problem when the app is in a package
- Is there a way to disable HTTP to only accept HTTPS?
- fix python version classifier HOT 1
- Typo in command in README.rst causes silent failure
- flask-uwsgi-websocket middlewares violate PEP-333
- How can I increase the maximum concurrent connection limit for my flask uwsgi websocket server? HOT 1
- `Advanced Usage` block in README refers to WebSocket.environ, which doesn't exist.
- ws connection failed 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 flask-uwsgi-websocket.