Code Monkey home page Code Monkey logo

Comments (4)

rayalan avatar rayalan commented on June 2, 2024

I dug into this a bit more. There seem to be a couple issues doing on here:

  1. 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.
  2. 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.

zeekay avatar zeekay commented on June 2, 2024

That seems like a nice solution, would you like to send a PR?

from flask-uwsgi-websocket.

rayalan avatar rayalan commented on June 2, 2024

I will; it may be a couple days.

from flask-uwsgi-websocket.

rayalan avatar rayalan commented on June 2, 2024

Created #48

from flask-uwsgi-websocket.

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.