rp2: Accept not responding on Pico W after 5 mins
Port, board and/or hardware
Raspberry Pi Pico W
MicroPython version
MicroPython v1.23.0 on 2024-06-02; Raspberry Pi Pico W with RP2040
Reproduction
import network
import socket
import time
ssid = 'SSID'
password = 'PASSWORD'
wlan = network.WLAN(network.STA_IF)
wlan.active(True)
wlan.connect(ssid, password)
while not wlan.isconnected():
time.sleep(1)
print("Connected", wlan.ifconfig()[0])
addr = socket.getaddrinfo('0.0.0.0', 80)[0][-1]
s = socket.socket()
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
s.bind(addr)
s.listen(1)
while True:
cl, addr = s.accept()
request = cl.recv(1024)
cl.send("HTTP/1.0 200 OK\r\nContent-type: text/html\r\n\r\n")
cl.send("<html><body>{}</body></html>".format(time.time()))
cl.close()
Expected behaviour
I expected the Pico W to accept requests and respond with the time (single integer) indefinitely.
Observed behaviour
Running the example code (which is a simplified version of the webserver example on the RPI site) I can send requests from FIrefox to thePico W ip address and get an imediate response. If the Pico W is left about 5 minutes or more with receiving a request then it no longer appears to accept on he socket.
Additional Information
If I put a timeout on the socket of 30 seconds the Pico W works for longer than 5 minutes but does eventually stop responding.
Putting a line into the html so that it refeshes every minute will keep the Pico responding for hours.
Code of Conduct
Yes, I agree
RP2 W fails to receive UDP datagrams
Port, board and/or hardware
Pico W on Raspberry Pi Pico W
MicroPython version
MicroPython v1.25.0-preview.295.g30acb16ad on 2025-02-11; Raspberry Pi Pico W with RP2040
Reproduction
Simple receive program for the Pico W to run after
initializing the wireless hardware:
import socket
server_default_port = 50000
soc = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
soc.bind(('', server_default_port))
l, sender_address = soc.recvfrom(128)
print('l =', l)
This never returns from the call to recvfrom.
It works fine using an Espressif ESP-WROOM-32 board.
Simple test client:
import socket
server_default_port = 50000
IP_address = '192.168.100.91'
server_address = (IP_address, server_default_port)
soc = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
x = b'#0 D256\n'
n = soc.sendto(x, server_address)
print('sent', n, 'bytes', 'to', server_address)
Expected behaviour
Should have received the transmitted message.
Observed behaviour
No message received.
Additional Information
No, I've provided everything above.
Code of Conduct
Yes, I agree