Secure Web Server or Web Socket Server on MicroPython #10341
Unanswered
pdr0663
asked this question in
Libraries & Drivers
Replies: 1 comment
-
@pdr0663 I think that your best option is microdot and these TLS examples microdot/examples/tls
This was what made it work at browser side in <script>
const log = (text, color) => {
document.getElementById('log').innerHTML += `<span style="color: ${color}">${text}</span><br>`;
};
const socket = new WebSocket('wss://' + location.host + '/echo');
socket.addEventListener('message', ev => {
log('<<< ' + ev.data, 'blue');
});
socket.addEventListener('close', ev => {
log('<<< closed');
});
document.getElementById('form').onsubmit = ev => {
ev.preventDefault();
const textField = document.getElementById('text');
log('>>> ' + textField.value, 'red');
socket.send(textField.value);
textField.value = '';
};
</script> Note the |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm enjoying MicroPython on various devices I have. I'm currently working on a navigation system for my boat. An ESP32 device is connected to two 32x8 LED dot matrix displays, which will show current speed and course, and distance and course to the next waypoint.
I have programmed a web page to present a user interface, and receive geolocation information from my phone, and process this information for display. The idea is that the ESP32 device will connect to the phone's hotspot, show the IP address on it's display, and I use the web page on the phone to enter the IP address, and connect to the ESP32 via web socket. The ESP32 would act as a socket server, and the web page will periodically send the geolocation information to the ESP32 for display.
It's all working, except for the web socket communication. It seems that mobile phone browsers are security obsessed. Here are a couple of configurations I've tried and failed with:
I have tried Chrome, Safari and Opera on iOS, and Chrome on Windows with the same results.
Is there a secure web socket library, available for MicroPython? Getting a certificate is relatively painless (I've done it before for a web server I set up). Is there also a secure web server library? I'm by no means an expert on the ip stuff, and the code I'm using is very straightforward, from the numerous examples available online for sockets and serving HTML, and interestingly, also from ChatGPT.
Regards,
Paul
Beta Was this translation helpful? Give feedback.
All reactions