MicroWebSrv2 icon indicating copy to clipboard operation
MicroWebSrv2 copied to clipboard

Cannot bind server on 0.0.0.0:80.

Open JohannesMaierhofer opened this issue 3 years ago • 3 comments

Hi, I'm trying to run MicroWebSrv2 on the Arduino RP2040 nano Connect via a wifi connection. But I ended up in MicroWebSrv2Exception: Cannot bind server on 0.0.0.0:80.

Here is my minimal example:

import network

SSID ='My_Nano_RP2040_Connect'   # Network SSID
KEY  ='1234567890'  # Network key (must be 10 chars)

# Init wlan module and connect to network
wlan = network.WLAN(network.AP_IF)
wlan.active(True)
wlan.config(essid=SSID, key=KEY, security=wlan.WEP, channel=2)
print("AP mode started. SSID: {} IP: {}".format(SSID, wlan.ifconfig()[0]))

from MicroWebSrv2 import *
from time         import sleep

mws2 = MicroWebSrv2()
mws2.SetEmbeddedConfig()
mws2.StartManaged()

# Main program loop until keyboard interrupt,
try :
    while True :
        sleep(1)
except KeyboardInterrupt :
    mws2.Stop()

JohannesMaierhofer avatar Feb 14 '22 23:02 JohannesMaierhofer

Additional information: The following line causes the issue, as it seems not available for the RP2 port of usocket. srvSocket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)

JohannesMaierhofer avatar Feb 15 '22 21:02 JohannesMaierhofer

I'm successfully running MWS2 on a Pico W, but I did have to manually use Bind() to specify my IP address and port, once I connected the W to the WLAN and had an IP. Letting it default-bind to 0.0.0.0 wasn't working.

concentrateddon avatar Nov 27 '22 16:11 concentrateddon

I'm successfully running MWS2 on a Pico W, but I did have to manually use Bind() to specify my IP address and port, once I connected the W to the WLAN and had an IP. Letting it default-bind to 0.0.0.0 wasn't working.

How did you manage to make it work ? Even manually binding the RPI Pico IP address and port, I am still getting the same error Cannot bind server on 192.168.1.113:8000, same with port 80 and IP 0.0.0.0

fschlaef avatar Apr 11 '24 12:04 fschlaef