Hi, I\’ve built a webserver on an ESP8266 Wemos D1, with Thonny and the sketch in \”ESP32/ESP8266 Micropython Web Server- Control Outputs\”
The server connects with the WLAN, gets the demand from the browser and then hangs.
The console shows: Connection successful(\’192.168.18.146\’, \’255.255.255.0\’, \’192.168.18.1\’, \’192.168.18.1\’)Got a connection from (\’192.168.18.176\’, 51708)Content = b\’GET / HTTP/1.1\\r\\nHost: 192.168.18.146\\r\\nConnection: keep-alive\\r\\nCache-Control: max-age=0\\r\\nDNT: 1\\r\\nUpgrade-Insecure-Requests: 1\\r\\nAccept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9\\r\\nAccept-Encoding: gzip, deflate\\r\\nUser-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/184.108.40.206 Safari/537.36 LikeWise/95.6.2265.66\\r\\nAccept-Language: es-ES,es;q=0.9,de-DE;q=0.8,de;q=0.7,fr-FR;q=0.6,fr;q=0.5,eu-ES;q=0.4,\’Got a connection from (\’192.168.18.176\’, 51710)
It does repeat it several times
When I stop the back end I get the following message
Traceback (most recent call last): File \”main.py\”, line 23, in <module>
Being line 23 : conn, addr = s.accept()>
On the browser I get: ERR_CONNECTION_RESET
I’d really appreciate any help. Thank you.
What is exaclty the code tat you’re trying to run? Can you share a link? We have several micropython web server projects…
´Thank you for your quick answer.
This is the page where I took the code from
I have to add that I assigned a fixed IP address to the ·ESP8266 and allowed it in the firewall.
Now one in four attempts I get the page requested on the computer but I haven’t been able of getting it on the mobile phone. On the computer, I’ve been able even to click on the buttons, but not to get a new page.
I’m sorry for taking so long to get back to you. I was out of the office during the last few days with little access to the internet.
Are you trying to open the web page on different devices at the same time?
If you’re trying it on your smartphone, I recommend closing the browser on your computer first.
Don’t worry, it’s been a quite busy week for me too.
I’ve tried connecting only with the laptop. I only get the name on the browser tab: ESP Web Sever, and a blank page.
I’ve taken the ESP8266 closer to de AP but it doesn’t make any difference.
When looking for APs with my laptop I can find the one of ESP8266.
Any further suggestions?
Do you have another ESP8266 to experiment with that is not a wemos?
If you do, please check with another board.
Yes, I have tried with another Wemos D1 and with an ESP 32, with similar results. I have as well reloaded the firmware with the “erase” option ticked on.
I just tested the project again and it is working.
If you have multiple tabs opened, it doesn’t work very well.
But if you just have one client opened at a time, it works as expected. I tested it on my PC web browser and on my smartphone.
I’m not sure if it might be an issue with your connection because of the IP address and firewall…
You are right!
I had too many tabs open. I have tried fresh from my mobile and has answered instantly. When ticking one option it gets hanged and gives a blank page, but the status has changed, as I can see loading the page again. Why could happen that?
Anyway I am really happy with the advance and very grateful for your advice.
I’m not sure… In my case, the page doesn’t hang. Only if I have multiple clients open.
A workaround to this issue is to use a non-blocking code for the webserver using uasyncio, for example: https://docs.micropython.org/en/latest/library/uasyncio.html
Unfortunately, I don’t have any example with uasyncio.
I found this library that combines uasyncio with web server features: https://github.com/belyalov/tinyweb
I hope this helps.