miguelgrinberg/microdot

WebSocket die and after a time HTTP die as well

Closed this issue · 4 comments

Hello @miguelgrinberg

I'm using ESP32-S3 with MicroPython 1.20, and I have a strange behaviour in rare times using websocket when I'm connecting from the browser (using your Websocket example) to ESP32-S3 just via SoftAP.

ESP32-S3 (SoftAP) 192.168.4.1 --- Notebook/SmartPhone (Android/IOS) (chrome/safari/firefox) running Microdot WebSocket Demo

When I put the IP 192.158.4.1 on the browser, shows the text edit, so I put the data and I press enter, but I have no feedback from echo. Shows no errors on console, and to back to works I need to reset the ESP32-S3.

There is some possibilities: bug on ESP32-S3 SoftAP, or MicroPython SoftAP causing incompatibility (in rare cases) with other clients, or can be a Microdot/WebSocket problem?

Unfortunately I can't find a way to reproduce this problem, it happens some times. If you have any idea to me investigate, like as a extra code for debug, etc, or maybe you think to add a extra code to manage this problem, I appreciate.

Thank you!

@miguelgrinberg I forgot to tell you a important information:

When I put 192.168.4.1 and press enter on the browser, Microdot receive the HTTP connect. But when I put data in the text edit and press enter, Microdot do not receive data.

In my application I have a log when I put 192.168.4.1 on browser and press enter:

DEBUG     |                      | 0158 __main__.http_server | Connected from host: 192.168.4.1 
DEBUG     |                      | 0030 ws_process._ws_connect | STARTED | Params: ws = <WebSocket object at 3def08d0> 
DEBUG     |                      | 0030 ws_process._ws_connect | STARTED | Params: ws = <WebSocket object at 3def08d0> 

I have a log as well when receive a websocket message, but nothing is printed when this bug happen.

@miguelgrinberg Hello, I have one more information:

New case: After some minutes trying sending data on text edit and not receiving data back (and nothing printing on microdot receive websocket), now even when I refresh browser (on ip 192.168.4.1) is not working anymore, I mean that print above of http server stopped printing and the Microdot WebSocket Demo do not show anymore, but the SmartPhone still connected to ESP32-S3 via SoftAP and pinging on it.

So, I did one more test with STA not stop anything at this moment. I enabled a AP where my application ESP32-S3 is ready to connect as STA. After ESP connected as STA, ESP receive IP 192.168.43.143, the same in all my tests as STA mode. But now I tried to open that ip (192.168.43.143) on the browser (as I always do) but do not open anything, like as the New case above, accessing via SoftAP - do not show the Microdot WebSocket Demo via STA as well. I still can ping to 192.68.43.143 on my notebook/smartphone, but in all browsers do not open anymore the Microdot WebSocket Demo. Is like as Microdot died, but I do no have any error message on console.

Can you look in the browser's console or network tab to see how the websocket connection appears there?

Can you look in the browser's console or network tab to see how the websocket connection appears there?

Hi @miguelgrinberg

I found the problem: this problem happen with the ESP32-S3 when I use SoftAP and STA mode simultaneously. In this case even to connect to WiFi from SmartPhone/notebook to ESP32-S3 AP mode is dificult (some times network goes down, or it is slow to connect and ping is very high) - I think that both active running ESP32-S3 multiplex the radio time between STA and SoftAP. But if I disable the STA mode, AP mode works very stable with Microdot, and vice-versa. So, can we to consider that this is not a problem of Microdot and we can close this issue, right?