-
Notifications
You must be signed in to change notification settings - Fork 100
Description
Hey, firstly - thank you for the great job writing this library, it's very easy to use. I used it in some of my projects before.
However I have encountered a problem in my recent project, trying to run this server on ESP32, or to be more precise - Wemos S2 mini.
In my main.py i run standard setup:
CONTENT = f"<h1>Hello, World!</h1><br>{values}"
@WebRoute(GET, '/test')
def RequestTest(microWebSrv2, request) :
request.Response.ReturnOk(content=CONTENT)
@WebRoute(GET, '/script.js')
def RequestTest(microWebSrv2, request) :
request.Response.ReturnFile("/www/script.js", None)
@WebRoute(GET, '/style.css')
def RequestTest(microWebSrv2, request) :
request.Response.ReturnFile("/www/style.css", None)
mws2 = MicroWebSrv2()
mws2.SetEmbeddedConfig()
mws2.StartManaged()
It is initialized correctly, but when I try to access device's IP via browser an exception is raised:
---------------------------
- Python pkg MicroWebSrv2 -
- version 2.0.6 -
- by JC`zic & HC2 -
---------------------------
+ [@WebRoute] GET /test
+ [@WebRoute] GET /script.js
+ [@WebRoute] GET /style.css
MWS2-INFO> Server listening on 0.0.0.0:80.
MWS2-INFO> Starts the managed pool to wait for I/O events.
Running...
Unhandled exception in thread started by <bound_method>
Traceback (most recent call last):
File "MicroWebSrv2/libs/XAsyncSockets.py", line 131, in _processWaitEvents
File "MicroWebSrv2/libs/XAsyncSockets.py", line 587, in OnReadyForReading
File "MicroWebSrv2/libs/XAsyncSockets.py", line 830, in IsSSL
AttributeError: 'module' object has no attribute 'SSLSocket'
it points to those lines of code from XAsyncSockets.py
@property
def IsSSL(self) :
return ( hasattr(ssl, 'SSLContext') and \
isinstance(self._socket, ssl.SSLSocket) )
when I add debugging print statement to this method
@property
def IsSSL(self) :
print(f"{ssl=} {type(ssl)=} {dir(ssl)=}")
return ( hasattr(ssl, 'SSLContext') and \
isinstance(self._socket, ssl.SSLSocket) )
that's the result:
MWS2-INFO> Server listening on 0.0.0.0:80.
MWS2-INFO> Starts the managed pool to wait for I/O events.
Running...
ssl=<module 'ssl'> type(ssl)=<class 'module'> dir(ssl)=['__class__', '__name__', '__dict__', 'CERT_NONE', 'CERT_OPTIONAL', 'CERT_REQUIRED', 'PROTOCOL_TLS_CLIENT', 'PROTOCOL_TLS_SERVER', 'SSLContext', 'wrap_socket']
Unhandled exception in thread started by <bound_method>
Traceback (most recent call last):
File "MicroWebSrv2/libs/XAsyncSockets.py", line 131, in _processWaitEvents
File "MicroWebSrv2/libs/XAsyncSockets.py", line 587, in OnReadyForReading
File "MicroWebSrv2/libs/XAsyncSockets.py", line 831, in IsSSL
AttributeError: 'module' object has no attribute 'SSLSocket'
Unfortunately I don't have a knowledge to figure out if ssl module is valid and why there's 'SSLSocket' attribute missing. Can you help me?
EDIT:
I also tried deleting second condition from "and" expression to see what happens next
@property
def IsSSL(self) :
print(f"{ssl=} {type(ssl)=} {dir(ssl)=}")
return hasattr(ssl, 'SSLContext')
But i got an error futher in this part of the same file:
if self.IsSSL and self._socket.pending() > 0 :
break
Traceback (most recent call last):
File "MicroWebSrv2/libs/XAsyncSockets.py", line 131, in _processWaitEvents
File "MicroWebSrv2/libs/XAsyncSockets.py", line 587, in OnReadyForReading
AttributeError: 'socket' object has no attribute 'pending'