BetaRavener/upy-websocket-server

websocket_helper

Closed this issue · 2 comments

I know this is an old code, there is no websocket_helper in current micropython port. Can you advise which one to use instead? The websocket server appears to have started as its printing the startup message. However when I connect to it using thirdparty websocket client, it connects and then immediately disconnects. How do you execute the given example to fetch the HTML?

What is the URL to access it from esp8266

This should be the original websocket_helper.py implementation, you can just deploy it to ESP with rest of the files: https://github.com/pfalcon/uremi/blob/master/websocket_helper.py

As to why it connects and disconnects - look for errors either on ESP or in the third party client. This implementation was only tested with some browsers, where it worked well, but it's not guaranteed to work with all websocket implementation. A hint of this comes from the websocket_helper.py itself: https://github.com/pfalcon/uremi/blob/master/websocket_helper.py#L57

ESP doesn't have URL by default, just IP assigned by router when you connect over WiFi. You need a DHCP server (not on ESP, in general) that can give name to an IP, though this will work only on your local network without more elaborate setup.

Thank you for replying, while waiting for your reply I just wrote an implementation of the websocket handshake protocol myself and it works. Its basically a few lines of HTTP headers being returned to the client. I am trying to get this working as an async server as it is continuously looping in your implementation.