Page 1 of 1

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

Posted: Sat Jan 15, 2022 6:31 pm
by beyonlo
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!

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

Posted: Sun Jan 16, 2022 9:23 am
by tangerino

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

Posted: Mon Jan 17, 2022 2:29 pm
by beyonlo
tangerino wrote:
Sun Jan 16, 2022 9:23 am
You can look at this
https://github.com/jczic/MicroWebSrv
That use thread, not uasyncio.

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

Posted: Tue Jan 18, 2022 10:11 pm
by bazooka07

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

Posted: Wed Jan 19, 2022 4:18 pm
by beyonlo
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.

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

Posted: Thu Jan 20, 2022 12:39 am
by marcidy
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.