Skip to content

800 bps when serving webpage with WSGIServer #174

Closed
@rivques

Description

@rivques

Hi! I've been messing around with a Metro M4 Airlift Lite and hit an interesting snag when trying to serve a webpage using Adafruit's esp32spi_wsgiserver and adafruit_wsgi.wsgi_app. (Code is here for those interested.) When serving the webpage, I was getting only about 800 bits per second, slow enough to cause Chrome to have issues recognizing the format of the page as HTML because (I assume) the <!DOCTYPE html> did not arrive quickly enough. After digging through debug=True logs and the various modules of adafruit_esp32spi, it seems like the issue is that WSGIServer.finish_response is sending data to ESP_SPIcontrol.socket_write one byte at a time. This bypasses socket_write's built-in chunking and seems to cause a lot of extra overhead, possibly due to #108. To fix this I use a slightly modified version of esp32spi_wsgiserver where I socket_write the entire response at once if possible instead of looping over every char in the response and writing it individually. This increased data rate to something like 178 kbps. Anyways, my questions are:

  1. Am I missing something that would cause this to be a non-issue?
  2. Is this a known issue and if so, is there another workaround?
  3. Would this problem be fixed by ESP_SPIcontrol._wait_for_ready is eating lots of time polling the READY/BUSY pin #108 being resolved?
  4. Is my workaround a reasonable one, or does it have pitfalls I can't see? If so, should I put it in a PR to this repo?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions