[Libwebsockets] Question about protocol-0 callback design in External Polling application
andy at warmcat.com
Mon May 11 19:13:48 CEST 2020
On 5/11/20 5:31 PM, John Peter Norair wrote:
> I’m building a websocket<—>unix-socket bridge. Perhaps one already
> exists, but I haven’t found it. I will open source my software if it
> ends up being worth releasing.
Yes it should work fine.
Lws already supports reverse proxying http and ws over a unix domain
socket (-DLWS_WITH_HTTP_PROXY=1). When you visit gitohashi or sai
actually that's a separate process than the lws-based webserver you're
connecting to, proxied over a unix domain socket at the server.
You can implement it using mounts like this example
Set the .origin to something like "+/var/run/sai:/sai" (the unix socket
path and then the proxied http base path) and .origin_protocol to
Mountpoint is where the proxy is placed in the url space of the server.
> I’m looking at this page (below). It seems simple enough.
> What’s less simple is extracting lws_callback_http_dummy() from the lws
> sources and removing the parts of it that link to sections I’d prefer
> not to include in my application sources (i.e. I’d prefer to keep them
> in the lib).
You don't need to do any of that.
> I would appreciate any guidance in minimizing lws_callback_http_dummy().
It's an export from lws
if you need something that's in it, you can just call through to the
library exported version if nothing else in your protocol wanted to
handle it, eg
> If there’s already a program or example that does this, even better.
> My application doesn’t require HTTP functionality beyond what’s shown
> in the minimal-examples/ws-server/minimal-ws-server example code (this
> uses lws_callback_http_dummy()).
> Best regards,
> Libwebsockets mailing list
> Libwebsockets at ml.libwebsockets.org
More information about the Libwebsockets