Simple example of uasyncio WebSocket Server (secure - with SSL)

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
beyonlo
Posts: 58
Joined: Thu Nov 26, 2015 8:03 pm

Simple example of uasyncio WebSocket Server (secure - with SSL)

Post by beyonlo » Sat Jan 15, 2022 6:31 pm

Hi all.

I would like a simple example of uasyncio WebSocket Server (secure - with SSL). I see that there is a official uwebsocket module implemented on MicroPython.

Code: Select all

>>> import os
>>> os.uname()
(sysname='esp32', nodename='esp32', release='1.17.0', version='v1.17 on 2021-09-02', machine='ESP32 module (spiram) with ESP32')
>>> import uwebsocket
>>>
Well, so I found a example (https://github.com/micropython/micropyt ... webrepl.py) that use the official uwebsocket module. Need just to add SSL + uasyncio on that example.


Thank you in advance!
Last edited by beyonlo on Wed Jan 19, 2022 4:15 pm, edited 2 times in total.

tangerino
Posts: 17
Joined: Sun Jul 25, 2021 8:34 am

Re: Simple example of uasyncio WebSocket Server (secure - with SSL)

Post by tangerino » Sun Jan 16, 2022 9:23 am


beyonlo
Posts: 58
Joined: Thu Nov 26, 2015 8:03 pm

Re: Simple example of uasyncio WebSocket Server (secure - with SSL)

Post by beyonlo » Mon Jan 17, 2022 2:29 pm

tangerino wrote:
Sun Jan 16, 2022 9:23 am
You can look at this
https://github.com/jczic/MicroWebSrv
That use thread, not uasyncio.


beyonlo
Posts: 58
Joined: Thu Nov 26, 2015 8:03 pm

Re: Simple example of uasyncio WebSocket Server (secure - with SSL)

Post by beyonlo » Wed Jan 19, 2022 4:18 pm

bazooka07 wrote:
Tue Jan 18, 2022 10:11 pm
https://github.com/pfalcon/picoweb.git
use uasyncio

The Picoweb do not support websocket. Even uasyncio on PicoWeb is old, it is not the official v3 uasyncio compatible, but it is good start point.

The https://github.com/jczic/MicroWebSrv use WebSocket, but is not official uwebsocket module - it wrote their own websocket module. And is better (if is possible) to use the official, for compatibility and so on.

This project https://github.com/Carglglz/upydev/tree/master/upyutils has a WebREPL example working with SSL using the official uwebsocket module - that is great. This project was put as a PR (https://github.com/micropython/micropython/pull/5611#) to support SSL in the official WebREPL, but I do not know why still not was merged, after two years.

I need just to know now how to add uasyncio on that WebREPL + SSL example.

marcidy
Posts: 133
Joined: Sat Dec 12, 2020 11:07 pm

Re: Simple example of uasyncio WebSocket Server (secure - with SSL)

Post by marcidy » Thu Jan 20, 2022 12:39 am

The 'uwebsocket' module which is used for the native webrepl is not "official," it's just there to help bootstrap a usable development environment. See comments here: https://github.com/micropython/micropython/issues/7149

i personally wouldn't include this as a requirement. A asyncio secure websocket webrepl is already a complex requirement.

Post Reply