jczic / MicroWebSrv2

The last Micro Web Server for IoTs (MicroPython) or large servers (CPython), that supports WebSockets, routes, template engine and with really optimized architecture (mem allocations, async I/Os). Ready for ESP32, STM32 on Pyboard, Pycom's chipsets (WiPy, LoPy, ...). Robust, efficient and documented!
https://github.com/jczic/MicroWebSrv2
MIT License
662 stars 97 forks source link

MicroWebSrv2 with urequests -- Wont' resolve FQDN while MicroWebSrv2 is running #93

Open interconnectix opened 1 year ago

interconnectix commented 1 year ago

I am running Micropython 1.20 on a ESP32-WROOM microcontroller with MiroWebSrv2 and urequests.

When MicroWebSrv2 is running (mws2.StartManaged()) I cannot use urequests to POST JSON to a FQDN domain. It will return an error of OSError(16,)

Code example below:


import urequests def sendInfo(): data = { "key:vaule" } try: response = urequests.post(http://somedomain.com/data/api, json=data) print("Response status code:", response.status_code) print("Response content:", response.content) except Exception as e: print("Error occurred during the request:") print(repr(e))

If I replace the FQDN domain with a IP address (random example IP below), it works as expected while MicroWebSrv2 is running. (mws2.StartManaged())


import urequests def sendInfo(): data = { "key:vaule" } try: response = urequests.post(http://8.8.8.8/data/api, json=data) print("Response status code:", response.status_code) print("Response content:", response.content) except Exception as e: print("Error occurred during the request:") print(repr(e))

Any suggestions on a resolution as it seems that it won't resolve DNS. (note: when I stop MicroWebSrv2 (mws2.Stop()), urequests can resolve a FQDN.)