ESP8266 Webserver Project

Moderator: Sprite_tm

User avatar
By Sprite_tm
#30167 FYI: I just pushed Websocket support into esphttpd. I know some people already wrote their own Websocket implementation, some of which are based on esphttpd, but I didn't really like the lack of integration of those... so I built my own. It's in the latest commit. The code is still young and hasn't been tested that much, so I'd love to get some feedback on it.
User avatar
By bjpirt
#30335 Sweet! I'm one of those people :-) One of the things I did which was specific to my use case was to set things up so that only one websocket could be opened at a time because it doesn't make sense when controlling a robot (or this one, anyway) to have multiple control channels open simultaneously. I programmed it so that the last request wins; if there's already a connection open, it sends an error message and closes it. Any idea if something like this might be easy to add to your implementation?

Nice to see the project growing, thanks.

Ben
User avatar
By azekie
#40642 I'm trying to call cgiWebsocketSend multiple time to send separate messages like the following:

cgiWebsocketSend(ws, data1, len1, WEBSOCK_FLAG_NONE);
cgiWebsocketSend(ws, data2, len2, WEBSOCK_FLAG_NONE);

Both functions are called and both return 1, but only first message is received by the client! Any idea how can I solve that?
Also, WS client disconnect after few seconds of inactivity, how can I avoid that?

I'm using Chrome Advanced REST Client for testing.
User avatar
By Sprite_tm
#40662 That is due to a limitation of the nonos-sdk combined with the way websockets work; the nonos-sdk doesn't allow sending more than one packet, so normally I use an internal buffer to send these packets. Because the websocket CGI isn't called from the http server context, I can't really use that internal buffer, though. For now, the best way probably is to manually concatenate the data and send it in one go. I'll try to fix up something in the websocket code that makes it possible to do it separately; if anyone has any thoughts about this, I'd be happy to hear them.