Closed
Description
If I do the GET request too quickly on a PICO W it gets stuck in an infinite loop.
I took inspiration from this issue on how to debug: #41
When I add print(bytes_sent, bytes_to_send)
to the response.py _send_bytes method I can see it gets stuck in an infinite loop.
Hard to capture in text as the board locks up and so does Mu serial connection I took a video and I've attached an image from the point where the issue happens.
code.py at the moment is:
import socketpool
import wifi
import os
from adafruit_httpserver.mime_type import MIMEType
from adafruit_httpserver.request import HTTPRequest
from adafruit_httpserver.response import HTTPResponse
from adafruit_httpserver.server import HTTPServer
if not wifi.radio.ipv4_address:
ssid = os.getenv('WIFI_SSID')
print(f"Connecting to Wifi: {ssid}")
wifi.radio.connect(ssid, os.getenv('WIFI_PASSWORD'))
print(f"Connected: IP address is {wifi.radio.ipv4_address}")
pool = socketpool.SocketPool(wifi.radio)
server = HTTPServer(pool)
server.socket_timeout = 0.25
count = 0
poll_count = 0
@server.route("/")
def base(request: HTTPRequest):
print(request.path, request.connection)
"""
Serve the default index.html file.
"""
with HTTPResponse(request, content_type=MIMEType.TYPE_HTML) as response:
response.send_file("index.html")
@server.route("/MUTE")
def mute(request: HTTPRequest):
print(request.path, request.connection)
"""
Serve the default index.html file.
"""
try:
global count
count = count + 1
print(f"{count} sending")
# device.send(0xE2)
with HTTPResponse(request, content_type=MIMEType.TYPE_HTML) as response:
response.send_file("index.html")
print(f"{count} sent")
except Exception as e:
print(e)
print(f"Listening on http://{wifi.radio.ipv4_address}:80")
# Start the server.
server.start(str(wifi.radio.ipv4_address))
while True:
try:
poll_count = poll_count + 1
if(poll_count % 10_000 == 0):
print(f"Polling {poll_count}")
server.poll()
if(poll_count % 10_000 == 0):
print(f"Poll Done {poll_count}")
except Exception as error:
print(error)
raise error
and index.html is:
<!DOCTYPE html>
<html lang="en">
<head>
<title>REMOTE</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.0.0/dist/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
</head>
<body class="bg-dark">
<div class="container-sm bg-dark rounded text-center">
<br>
<div class="row">
<div class="col-1">
<div class="text-light">
<a class="btn brn-dark btn-lg text-light btn-outline-primary" href="/MUTE" role="button"> 🔈 </a>
</div>
</div>
</div>
</div>
</body>
</html>
Metadata
Metadata
Assignees
Labels
No labels