[Libwebsockets] new plugin: session-cgi

Void Your Warranty voidyourwarranty at mailbox.org
Sun Oct 14 02:36:43 CEST 2018


thank you to Andy and the community for this fantastic library!

I needed the following functionality: For each session that upgrades to web sockets, the server spawns a new process in which it runs a certain executable ("application"). All messages from the client go to the standard input of the application, and the standard output of the application is sent back to the client.

This is because I wanted to play around with web sockets, but I didn't want to use node.js because I don't want to program the application logic in javascript. I also didn't want to program the application logic in C/C++, but, hey, I can still use libwebsockets and lwsws in order to "feed" all incoming messages to my own executable and vice versa. I am then free to use any language I like for my application. The only downside is that different sessions can no longer "see each other" at web server level. Luckily, this is no problem im my case and I suppose in many other situations, too. Most applications probably use some persistent data base, and so a common data base is a way that different sessions can interact.

As I wasn't able to find such a functionality (neither anywhere else nor here), I tried to cook up a new protocol for libwebsockets. I call it "session-cgi" because it is like good old CGI applied to the individual web socket sessions. Here is the plugin I came up with:


Please feel free to use it and perhaps tell me what you (dis)like.

Kind regards,

Void Your Warranty

More information about the Libwebsockets mailing list