warmcat / libwebsockets

canonical libwebsockets.org networking library
https://libwebsockets.org
Other
4.8k stars 1.49k forks source link

lws_callback_http_dummy doesn't reply 404 for non-existent mount files #3255

Closed stevensonkd closed 3 weeks ago

stevensonkd commented 3 weeks ago

My application is similar to the minimal-ws-server example. I want to serve static files, so protocols[0] uses lws_callback_http_dummy to handle a mount, and protocols[1] is my WebSocket protocol.

I want my WebSocket clients to be able to negotiate without a protocol name, so per the "Working without a protocol name" section in README.coding.md, I add the per-vhost option "default".

However, if I add this per-vhost option, my application no longer replies with 404 to requests for files that don't exist under the mount. It works as expected for files that exist. But for non-existent files, it doesn't return any data to the client; it just sits there, keeping the connection open (until the 10s timeout elapses).

I can reproduce this with the minimal-ws-server example, just by adding that per-vhost option:

--- a/minimal-examples-lowlevel/ws-server/minimal-ws-server/minimal-ws-server.c
+++ b/minimal-examples-lowlevel/ws-server/minimal-ws-server/minimal-ws-server.c
@@ -55,10 +55,9 @@ static const struct lws_http_mount mount = {
        /* .basic_auth_login_file */    NULL,
 };

-#if defined(LWS_WITH_PLUGINS)
 /* if plugins enabled, only protocols explicitly named in pvo bind to vhost */
-static struct lws_protocol_vhost_options pvo = { NULL, NULL, "lws-minimal", "" };
-#endif
+static struct lws_protocol_vhost_options pvo_opt = { NULL, NULL, "default", "1"};
+static struct lws_protocol_vhost_options pvo = { NULL, &pvo_opt, "lws-minimal", "" };

 void sigint_handler(int sig)
 {
@@ -91,9 +90,7 @@ int main(int argc, const char **argv)
        info.mounts = &mount;
        info.protocols = protocols;
        info.vhost_name = "localhost";
-#if defined(LWS_WITH_PLUGINS)
        info.pvo = &pvo;
-#endif
        info.options =
                LWS_SERVER_OPTION_HTTP_HEADERS_SECURITY_BEST_PRACTICES_ENFORCE;

I've tested with Ubuntu 20.04 (lws 3.2.1) and Alpine 3.20 (lws 4.3.3). Same result.

Is this a bug? Or am I doing something wrong here?

lws-team commented 3 weeks ago

What do the detailed logs say?

stevensonkd commented 3 weeks ago

Here are the logs from running the patched minimal-ws-server. The request is at 14:16:41:7219. This was with Ubuntu 24.04 (lws 4.3.3).

[2024/10/30 14:16:31:4593] U: LWS minimal ws server | visit http://localhost:7681 (-s = use TLS / https)
[2024/10/30 14:16:31:4593] I: lws_create_context: ev lib path /usr/lib/x86_64-linux-gnu, '(null)'
[2024/10/30 14:16:31:4593] D: _realloc: size 7392: context
[2024/10/30 14:16:31:4593] N: localhost: lws_create_context: LWS: 4.3.3-unknown, NET CLI SRV H1 H2 WS ConMon IPV6-on
[2024/10/30 14:16:31:4593] I: localhost: lws_create_context: Event loop: poll
[2024/10/30 14:16:31:4593] D: _realloc: size 64: lws_smd_register
[2024/10/30 14:16:31:4593] I: localhost: lws_smd_register: peer 0x5588cb37e190 (count 1) registered
[2024/10/30 14:16:31:4593] D: _realloc: size 8388608: fds table
[2024/10/30 14:16:31:4630] I: localhost: lws_create_context: ctx:  6160B (2064 ctx + pt(1 thr x 4096)), pt-fds: 1048576, fdmap: 8388608
[2024/10/30 14:16:31:4630] I: localhost: lws_create_context:  http: ah_data: 4096, ah: 984, max count 1048576
[2024/10/30 14:16:31:4630] D: _realloc: size 8388608: lws_lookup
[2024/10/30 14:16:31:4666] I: localhost: lws_plat_init:  mem: platform fd map: 8388608 B
[2024/10/30 14:16:31:4666] D: _realloc: size 1232: __lws_wsi_create_with_role
[2024/10/30 14:16:31:4666] D: : lws_role_transition: wsistate 0x200, ops pipe
[2024/10/30 14:16:31:4666] N: localhost: __lws_lc_tag:  ++ [wsi|0|pipe] (1)
[2024/10/30 14:16:31:4666] D: [wsi|0|pipe]: __insert_wsi_socket_into_fds: tsi=0, sock=4, pos-in-fds=0
[2024/10/30 14:16:31:4667] I: localhost: rops_pt_init_destroy_netlink: creating netlink skt
[2024/10/30 14:16:31:4667] D: _realloc: size 1232: __lws_wsi_create_with_role
[2024/10/30 14:16:31:4667] D: : lws_role_transition: wsistate 0x200, ops netlink
[2024/10/30 14:16:31:4667] N: localhost: __lws_lc_tag:  ++ [vh|0|netlink] (1)
[2024/10/30 14:16:31:4667] D: [vh|0|netlink]: __insert_wsi_socket_into_fds: tsi=0, sock=5, pos-in-fds=1
[2024/10/30 14:16:31:4667] D: localhost: rops_pt_init_destroy_netlink: starting netlink coldplug wait
[2024/10/30 14:16:31:4667] I: localhost: lws_context_init_ssl_library:  Compiled with OpenSSL support
[2024/10/30 14:16:31:4667] I: localhost: lws_context_init_ssl_library:  SSL disabled: no LWS_SERVER_OPTION_DO_SSL_GLOBAL_INIT
[2024/10/30 14:16:31:4667] I: localhost: lws_server_get_canonical_hostname:  canonical_hostname = 885b291bfbf0
[2024/10/30 14:16:31:4667] D: _realloc: size 906: lws_create_vhost
[2024/10/30 14:16:31:4668] N: localhost: __lws_lc_tag:  ++ [vh|1|localhost||7681] (2)
[2024/10/30 14:16:31:4668] D: _realloc: size 168: vh plugin table
[2024/10/30 14:16:31:4668] D: _realloc: size 48: same vh list
[2024/10/30 14:16:31:4668] I: [vh|1|localhost||7681]: lws_create_vhost: Creating Vhost 'localhost' port 7681, 2 protocols, IPv6 on
[2024/10/30 14:16:31:4668] I: [vh|1|localhost||7681]: lws_create_vhost:    mounting file://./mount-origin to /
[2024/10/30 14:16:31:4668] I: _lws_vhost_init_server_af: af 2
[2024/10/30 14:16:31:4669] N: [vh|1|localhost||7681]: lws_socket_bind: source ads 0.0.0.0
[2024/10/30 14:16:31:4669] D: _realloc: size 1232: __lws_wsi_create_with_role
[2024/10/30 14:16:31:4669] D: : lws_role_transition: wsistate 0x200, ops listen
[2024/10/30 14:16:31:4669] D: _lws_vhost_init_server_af: lws_socket_bind says 7681
[2024/10/30 14:16:31:4669] D: : lws_vhost_bind_wsi: vh localhost: wsi listen/http, count_bound_wsi 1
[2024/10/30 14:16:31:4669] D: : __insert_wsi_socket_into_fds: tsi=0, sock=6, pos-in-fds=2
[2024/10/30 14:16:31:4669] N: localhost: __lws_lc_tag:  ++ [wsi|1|listen|localhost||7681] (2)
[2024/10/30 14:16:31:4669] I:  Listening on (null):7681
[2024/10/30 14:16:31:4669] I: _lws_vhost_init_server_af: af 10
[2024/10/30 14:16:31:4670] N: [vh|1|localhost||7681]: lws_socket_bind: source ads ::
[2024/10/30 14:16:31:4670] D: _realloc: size 1232: __lws_wsi_create_with_role
[2024/10/30 14:16:31:4670] D: : lws_role_transition: wsistate 0x200, ops listen
[2024/10/30 14:16:31:4670] D: _lws_vhost_init_server_af: lws_socket_bind says 7681
[2024/10/30 14:16:31:4670] D: : lws_vhost_bind_wsi: vh localhost: wsi listen/http, count_bound_wsi 2
[2024/10/30 14:16:31:4670] D: : __insert_wsi_socket_into_fds: tsi=0, sock=7, pos-in-fds=3
[2024/10/30 14:16:31:4670] N: localhost: __lws_lc_tag:  ++ [wsi|2|listen|localhost||7681] (3)
[2024/10/30 14:16:31:4670] I:  Listening on (null):7681
[2024/10/30 14:16:31:4670] I: localhost: lws_context_init_extensions:  LWS_MAX_EXTENSIONS_ACTIVE: 1
[2024/10/30 14:16:31:4670] I: localhost: lws_create_context:  mem: per-conn:         1232 bytes + protocol rx buf
[2024/10/30 14:16:31:4670] I: localhost: lws_plat_drop_app_privileges: not changing group
[2024/10/30 14:16:31:4670] I: localhost: lws_plat_drop_app_privileges: not changing user
[2024/10/30 14:16:31:4670] D: localhost: lws_cancel_service: 
[2024/10/30 14:16:31:4670] D: localhost: _lws_state_transition: system: changed 1 'CONTEXT_CREATED' -> 2 'INITIALIZED'
[2024/10/30 14:16:31:4670] I: localhost: lws_state_notify_protocol_init: waiting for netlink coldplug
[2024/10/30 14:16:31:4670] I: localhost: _report: system: prot_init: rejected 'INITIALIZED' -> 'IFACE_COLDPLUG'
[2024/10/30 14:16:31:4670] I: localhost: lws_state_transition_steps: CONTEXT_CREATED -> INITIALIZED
[2024/10/30 14:16:31:4670] I: localhost: lws_protocol_init: 
[2024/10/30 14:16:31:4670] D: [vh|1|localhost||7681]: lws_protocol_init_vhost: not instantiating http
[2024/10/30 14:16:31:4670] D: [vh|1|localhost||7681]: lws_protocol_init_vhost: protocol "lws-minimal", option "default"
[2024/10/30 14:16:31:4671] I: [vh|1|localhost||7681]: lws_protocol_init_vhost: Setting default protocol to lws-minimal
[2024/10/30 14:16:31:4671] I: [vh|1|localhost||7681]: lws_protocol_init_vhost: init localhost.lws-minimal
[2024/10/30 14:16:31:4671] D: _realloc: size 16: protocol_vh_privs
[2024/10/30 14:16:31:4671] D: _realloc: size 56: vh priv
[2024/10/30 14:16:31:4671] I: localhost: rops_handle_POLLIN_netlink: RTM 24
[2024/10/30 14:16:31:4671] I: localhost: rops_handle_POLLIN_netlink: NEWROUTE
[2024/10/30 14:16:31:4671] I: localhost: rops_handle_POLLIN_netlink: ifidx 311
[2024/10/30 14:16:31:4671] I: localhost: rops_handle_POLLIN_netlink: NEWROUTE rtm_type 1
[2024/10/30 14:16:31:4671] D: _realloc: size 144: rops_handle_POLLIN_netlink
[2024/10/30 14:16:31:4671] I: localhost: rops_handle_POLLIN_netlink: route list size 1
[2024/10/30 14:16:31:4671] D: _realloc: size 63: lws_smd_msg_alloc
[2024/10/30 14:16:31:4671] D: localhost: lws_cancel_service: 
[2024/10/30 14:16:31:4671] I: localhost: rops_handle_POLLIN_netlink: RTM 24
[2024/10/30 14:16:31:4671] I: localhost: rops_handle_POLLIN_netlink: NEWROUTE
[2024/10/30 14:16:31:4671] I: localhost: rops_handle_POLLIN_netlink: RTA_DST: 172.17.0.0
[2024/10/30 14:16:31:4671] I: localhost: rops_handle_POLLIN_netlink: RTA_SRC: 172.17.0.3
[2024/10/30 14:16:31:4671] I: localhost: rops_handle_POLLIN_netlink: ifidx 311
[2024/10/30 14:16:31:4671] I: localhost: rops_handle_POLLIN_netlink: NEWROUTE rtm_type 1
[2024/10/30 14:16:31:4671] D: _realloc: size 144: rops_handle_POLLIN_netlink
[2024/10/30 14:16:31:4671] I: localhost: rops_handle_POLLIN_netlink: route list size 2
[2024/10/30 14:16:31:4671] D: _realloc: size 63: lws_smd_msg_alloc
[2024/10/30 14:16:31:4672] D: localhost: lws_cancel_service: 
[2024/10/30 14:16:31:4672] I: localhost: rops_handle_POLLIN_netlink: RTM 24
[2024/10/30 14:16:31:4672] I: localhost: rops_handle_POLLIN_netlink: NEWROUTE
[2024/10/30 14:16:31:4672] I: localhost: rops_handle_POLLIN_netlink: RTA_DST: 127.0.0.0
[2024/10/30 14:16:31:4672] I: localhost: rops_handle_POLLIN_netlink: RTA_SRC: 127.0.0.1
[2024/10/30 14:16:31:4672] I: localhost: rops_handle_POLLIN_netlink: ifidx 1
[2024/10/30 14:16:31:4672] I: localhost: rops_handle_POLLIN_netlink: NEWROUTE rtm_type 3
[2024/10/30 14:16:31:4672] I: localhost: rops_handle_POLLIN_netlink: RTM 24
[2024/10/30 14:16:31:4672] I: localhost: rops_handle_POLLIN_netlink: NEWROUTE
[2024/10/30 14:16:31:4672] I: localhost: rops_handle_POLLIN_netlink: RTA_DST: 127.0.0.0
[2024/10/30 14:16:31:4672] I: localhost: rops_handle_POLLIN_netlink: RTA_SRC: 127.0.0.1
[2024/10/30 14:16:31:4672] I: localhost: rops_handle_POLLIN_netlink: ifidx 1
[2024/10/30 14:16:31:4672] I: localhost: rops_handle_POLLIN_netlink: NEWROUTE rtm_type 2
[2024/10/30 14:16:31:4672] D: _realloc: size 144: rops_handle_POLLIN_netlink
[2024/10/30 14:16:31:4672] I: localhost: rops_handle_POLLIN_netlink: route list size 3
[2024/10/30 14:16:31:4672] D: _realloc: size 63: lws_smd_msg_alloc
[2024/10/30 14:16:31:4672] D: localhost: lws_cancel_service: 
[2024/10/30 14:16:31:4672] I: localhost: rops_handle_POLLIN_netlink: RTM 24
[2024/10/30 14:16:31:4672] I: localhost: rops_handle_POLLIN_netlink: NEWROUTE
[2024/10/30 14:16:31:4672] I: localhost: rops_handle_POLLIN_netlink: Local addr: RTA_DST -> added to RTA_SRC
[2024/10/30 14:16:31:4672] I: localhost: rops_handle_POLLIN_netlink: RTA_DST: 127.0.0.1
[2024/10/30 14:16:31:4672] I: localhost: rops_handle_POLLIN_netlink: RTA_SRC: 127.0.0.1
[2024/10/30 14:16:31:4672] I: localhost: rops_handle_POLLIN_netlink: ifidx 1
[2024/10/30 14:16:31:4672] I: localhost: rops_handle_POLLIN_netlink: NEWROUTE rtm_type 2
[2024/10/30 14:16:31:4672] D: _realloc: size 144: rops_handle_POLLIN_netlink
[2024/10/30 14:16:31:4672] I: localhost: rops_handle_POLLIN_netlink: route list size 4
[2024/10/30 14:16:31:4672] D: _realloc: size 63: lws_smd_msg_alloc
[2024/10/30 14:16:31:4672] D: localhost: lws_cancel_service: 
[2024/10/30 14:16:31:4672] I: localhost: rops_handle_POLLIN_netlink: RTM 24
[2024/10/30 14:16:31:4672] I: localhost: rops_handle_POLLIN_netlink: NEWROUTE
[2024/10/30 14:16:31:4672] I: localhost: rops_handle_POLLIN_netlink: RTA_DST: 127.255.255.255
[2024/10/30 14:16:31:4672] I: localhost: rops_handle_POLLIN_netlink: RTA_SRC: 127.0.0.1
[2024/10/30 14:16:31:4673] I: localhost: rops_handle_POLLIN_netlink: ifidx 1
[2024/10/30 14:16:31:4673] I: localhost: rops_handle_POLLIN_netlink: NEWROUTE rtm_type 3
[2024/10/30 14:16:31:4673] I: localhost: rops_handle_POLLIN_netlink: RTM 24
[2024/10/30 14:16:31:4673] I: localhost: rops_handle_POLLIN_netlink: NEWROUTE
[2024/10/30 14:16:31:4673] I: localhost: rops_handle_POLLIN_netlink: RTA_DST: 172.17.0.0
[2024/10/30 14:16:31:4673] I: localhost: rops_handle_POLLIN_netlink: RTA_SRC: 172.17.0.3
[2024/10/30 14:16:31:4673] I: localhost: rops_handle_POLLIN_netlink: ifidx 311
[2024/10/30 14:16:31:4673] I: localhost: rops_handle_POLLIN_netlink: NEWROUTE rtm_type 3
[2024/10/30 14:16:31:4673] I: localhost: rops_handle_POLLIN_netlink: RTM 24
[2024/10/30 14:16:31:4673] I: localhost: rops_handle_POLLIN_netlink: NEWROUTE
[2024/10/30 14:16:31:4673] I: localhost: rops_handle_POLLIN_netlink: Local addr: RTA_DST -> added to RTA_SRC
[2024/10/30 14:16:31:4673] I: localhost: rops_handle_POLLIN_netlink: RTA_DST: 172.17.0.3
[2024/10/30 14:16:31:4673] I: localhost: rops_handle_POLLIN_netlink: RTA_SRC: 172.17.0.3
[2024/10/30 14:16:31:4673] I: localhost: rops_handle_POLLIN_netlink: ifidx 311
[2024/10/30 14:16:31:4673] I: localhost: rops_handle_POLLIN_netlink: NEWROUTE rtm_type 2
[2024/10/30 14:16:31:4673] D: _realloc: size 144: rops_handle_POLLIN_netlink
[2024/10/30 14:16:31:4673] I: localhost: rops_handle_POLLIN_netlink: route list size 5
[2024/10/30 14:16:31:4673] D: _realloc: size 63: lws_smd_msg_alloc
[2024/10/30 14:16:31:4673] D: localhost: lws_cancel_service: 
[2024/10/30 14:16:31:4673] I: localhost: rops_handle_POLLIN_netlink: RTM 24
[2024/10/30 14:16:31:4673] I: localhost: rops_handle_POLLIN_netlink: NEWROUTE
[2024/10/30 14:16:31:4673] I: localhost: rops_handle_POLLIN_netlink: RTA_DST: 172.17.255.255
[2024/10/30 14:16:31:4673] I: localhost: rops_handle_POLLIN_netlink: RTA_SRC: 172.17.0.3
[2024/10/30 14:16:31:4673] I: localhost: rops_handle_POLLIN_netlink: ifidx 311
[2024/10/30 14:16:31:4673] I: localhost: rops_handle_POLLIN_netlink: NEWROUTE rtm_type 3
[2024/10/30 14:16:31:4673] D: _realloc: size 92: lws_smd_msg_alloc
[2024/10/30 14:16:31:4673] D: localhost: lws_cancel_service: 
[2024/10/30 14:16:31:4673] I: localhost: _lws_routing_table_dump: 
[2024/10/30 14:16:31:4673] I: localhost: _lws_routing_entry_dump:  gw: 172.17.0.1,  ifidx: 311, pri: -1, proto: 3
[2024/10/30 14:16:31:4673] I: localhost: _lws_routing_entry_dump:  dst: 172.17.0.0/16, src: 172.17.0.3/0,  ifidx: 311, pri: -1, proto: 2
[2024/10/30 14:16:31:4673] I: localhost: _lws_routing_entry_dump:  dst: 127.0.0.0/8, src: 127.0.0.1/0,  ifidx: 1, pri: -1, proto: 2
[2024/10/30 14:16:31:4674] I: localhost: _lws_routing_entry_dump:  dst: 127.0.0.1/32, src: 127.0.0.1/0,  ifidx: 1, pri: -1, proto: 2
[2024/10/30 14:16:31:4674] I: localhost: _lws_routing_entry_dump:  dst: 172.17.0.3/32, src: 172.17.0.3/0,  ifidx: 311, pri: -1, proto: 2
[2024/10/30 14:16:31:4674] I: localhost: _lws_smd_msg_deliver_peer: deliver cl 0x4, len 13, refc 1, to peer 0x5588cb37e190
[2024/10/30 14:16:31:4674] I: localhost: _lws_smd_msg_destroy: destroy msg 0x5588cb37faf0
[2024/10/30 14:16:31:4674] I: localhost: _lws_smd_msg_deliver_peer: deliver cl 0x4, len 13, refc 1, to peer 0x5588cb37e190
[2024/10/30 14:16:31:4674] I: localhost: _lws_smd_msg_destroy: destroy msg 0x5588cb37fbe0
[2024/10/30 14:16:31:4674] I: localhost: _lws_smd_msg_deliver_peer: deliver cl 0x4, len 13, refc 1, to peer 0x5588cb37e190
[2024/10/30 14:16:31:4674] I: localhost: _lws_smd_msg_destroy: destroy msg 0x5588cb37fcd0
[2024/10/30 14:16:31:4674] I: localhost: _lws_smd_msg_deliver_peer: deliver cl 0x4, len 13, refc 1, to peer 0x5588cb37e190
[2024/10/30 14:16:31:4674] I: localhost: _lws_smd_msg_destroy: destroy msg 0x5588cb37fdc0
[2024/10/30 14:16:31:4674] I: localhost: _lws_smd_msg_deliver_peer: deliver cl 0x4, len 13, refc 1, to peer 0x5588cb37e190
[2024/10/30 14:16:31:4674] I: localhost: _lws_smd_msg_destroy: destroy msg 0x5588cb37feb0
[2024/10/30 14:16:31:4674] I: localhost: _lws_smd_msg_deliver_peer: deliver cl 0x4, len 42, refc 1, to peer 0x5588cb37e190
[2024/10/30 14:16:31:4674] I: localhost: _lws_smd_msg_destroy: destroy msg 0x5588cb37ff00
[2024/10/30 14:16:31:4674] I: localhost: rops_handle_POLLIN_netlink: RTM 3
[2024/10/30 14:16:31:4674] I: localhost: rops_handle_POLLIN_netlink: *** Unknown RTM_3
[2024/10/30 14:16:31:5676] D: localhost: _lws_state_transition: system: changed 2 'INITIALIZED' -> 3 'IFACE_COLDPLUG'
[2024/10/30 14:16:31:5677] D: localhost: _lws_state_transition: system: changed 3 'IFACE_COLDPLUG' -> 4 'DHCP'
[2024/10/30 14:16:31:5677] D: localhost: _lws_state_transition: system: changed 4 'DHCP' -> 5 'CPD_PRE_TIME'
[2024/10/30 14:16:31:5677] D: localhost: _lws_state_transition: system: changed 5 'CPD_PRE_TIME' -> 6 'TIME_VALID'
[2024/10/30 14:16:31:5677] D: localhost: _lws_state_transition: system: changed 6 'TIME_VALID' -> 7 'CPD_POST_TIME'
[2024/10/30 14:16:31:5677] D: localhost: _lws_state_transition: system: changed 7 'CPD_POST_TIME' -> 8 'POLICY_VALID'
[2024/10/30 14:16:31:5677] D: localhost: _lws_state_transition: system: changed 8 'POLICY_VALID' -> 9 'REGISTERED'
[2024/10/30 14:16:31:5677] D: localhost: _lws_state_transition: system: changed 9 'REGISTERED' -> 10 'AUTH1'
[2024/10/30 14:16:31:5677] D: localhost: _lws_state_transition: system: changed 10 'AUTH1' -> 11 'AUTH2'
[2024/10/30 14:16:31:5677] D: localhost: _lws_state_transition: system: changed 11 'AUTH2' -> 12 'OPERATIONAL'
[2024/10/30 14:16:31:5677] I: localhost: lws_state_transition_steps: INITIALIZED -> OPERATIONAL
[2024/10/30 14:16:41:7219] D: accepted new conn port 36608 on fd=8
[2024/10/30 14:16:41:7220] D: localhost: lws_get_idlest_tsi: 4 1048575
[2024/10/30 14:16:41:7220] D: _realloc: size 1232: __lws_wsi_create_with_role
[2024/10/30 14:16:41:7220] D: : lws_role_transition: wsistate 0x200, ops (unset)
[2024/10/30 14:16:41:7220] N: localhost: __lws_lc_tag:  ++ [wsisrv|0|adopted] (1)
[2024/10/30 14:16:41:7220] D: [wsisrv|0|adopted]: lws_create_new_server_wsi: joining vh localhost, tsi 0
[2024/10/30 14:16:41:7220] D: [wsisrv|0|adopted]: lws_vhost_bind_wsi: vh localhost: wsi none/none, count_bound_wsi 3
[2024/10/30 14:16:41:7220] D: [wsisrv|0|adopted]: lwsi_set_state: lwsi_set_state 0x20000200 -> 0x20000200
[2024/10/30 14:16:41:7220] D: [wsisrv|0|adopted]: lws_role_transition: wsistate 0x20000016, ops h1
[2024/10/30 14:16:41:7220] D: [wsisrv|0|adopted]: __lws_set_timeout: 15 secs, reason 3
[2024/10/30 14:16:41:7220] D: [wsisrv|0|adopted]: __insert_wsi_socket_into_fds: tsi=0, sock=8, pos-in-fds=4
[2024/10/30 14:16:41:7220] I: lws_header_table_attach: [wsisrv|0|adopted]: ah (nil) (tsi 0, count = 0) in
[2024/10/30 14:16:41:7220] D: _realloc: size 984: ah struct
[2024/10/30 14:16:41:7220] D: _realloc: size 4096: ah data
[2024/10/30 14:16:41:7220] I: _lws_create_ah: created ah 0x5588cb380450 (size 4096): pool length 1
[2024/10/30 14:16:41:7220] D: [wsisrv|0|adopted]: _lws_change_pollfd: fd 8 events 1 -> 1
[2024/10/30 14:16:41:7220] I: lws_header_table_attach: did attach wsi [wsisrv|0|adopted]: ah 0x5588cb380450: count 1 (on exit)
[2024/10/30 14:16:41:7220] D: [wsisrv|0|adopted]: __lws_set_timeout: 10 secs, reason 25
[2024/10/30 14:16:41:7220] D: Attached ah immediately
[2024/10/30 14:16:41:7221] D: rops_handle_POLLIN_h1: [wsisrv|0|adopted]: wsistate 0x20000016
[2024/10/30 14:16:41:7221] D: [wsisrv|0|adopted]: lws_buflist_aware_read: lws_h1_server_socket_service: ssl_capable_read 82
[2024/10/30 14:16:41:7221] D: lws_read_h1: h1 path: wsi state 0x16
[2024/10/30 14:16:41:7221] I: lws_handshake_server: parsed count 82
[2024/10/30 14:16:41:7221] I: SNI: Found: localhost:7681
[2024/10/30 14:16:41:7221] D: [wsisrv|0|adopted]: lwsi_set_state: lwsi_set_state 0x20000016 -> 0x2000020a
[2024/10/30 14:16:41:7221] I: lws_handshake_server: [wsisrv|0|adopted]: No upgrade
[2024/10/30 14:16:41:7221] D: [wsisrv|0|adopted]: lwsi_set_state: lwsi_set_state 0x2000020a -> 0x20000119
[2024/10/30 14:16:41:7221] D: lws_handshake_server: [wsisrv|0|adopted]: ah 0x5588cb380450
[2024/10/30 14:16:41:7221] I: Method: 'GET' (0), request for '/nope'
[2024/10/30 14:16:41:7221] D: _realloc: size 24: user space
[2024/10/30 14:16:41:7221] D: [wsisrv|0|adopted]: __lws_set_timeout: 15 secs, reason 10
[2024/10/30 14:16:41:7222] I: lws_http_serve: Unable to open './mount-origin/nope': errno 2
[2024/10/30 14:16:41:7222] D: wsi->http.rx_content_length 0 0 0
[2024/10/30 14:16:56:7363] I: [wsisrv|0|adopted]: lws_sul_wsitimeout_cb: TIMEDOUT WAITING 10, dhdr 1, ah 0x5588cb380450, wl 0
[2024/10/30 14:16:56:7364] I: [wsisrv|0|adopted]: __lws_close_free_wsi: caller: timeout
[2024/10/30 14:16:56:7364] D: [wsisrv|0|adopted]: __lws_close_free_wsi: real just_kill_connection A: (sockfd 8)
[2024/10/30 14:16:56:7364] I: [wsisrv|0|adopted]: __lws_close_free_wsi: real just_kill_connection: sockfd 8
[2024/10/30 14:16:56:7364] D: [wsi|1|listen|localhost||7681]: _lws_change_pollfd: fd 6 events 1 -> 1
[2024/10/30 14:16:56:7365] D: [wsi|2|listen|localhost||7681]: _lws_change_pollfd: fd 7 events 1 -> 1
[2024/10/30 14:16:56:7365] D: [wsisrv|0|adopted]: lwsi_set_state: lwsi_set_state 0x20000119 -> 0x20000020
[2024/10/30 14:16:56:7365] I: [wsisrv|0|adopted]: __lws_close_free_wsi: cce=1
[2024/10/30 14:16:56:7365] D: [wsisrv|0|adopted]: __lws_close_free_wsi_final: fd 8
[2024/10/30 14:16:56:7367] D: [wsi|1|listen|localhost||7681]: _lws_change_pollfd: fd 6 events 1 -> 1
[2024/10/30 14:16:56:7367] D: [wsi|2|listen|localhost||7681]: _lws_change_pollfd: fd 7 events 1 -> 1
[2024/10/30 14:16:56:7407] I: rops_destroy_role_h1: ah det due to close
[2024/10/30 14:16:56:7408] I: __lws_header_table_detach: [wsisrv|0|adopted]: ah 0x5588cb380450 (tsi=0, count = 1)
[2024/10/30 14:16:56:7408] D: __lws_header_table_detach: [wsisrv|0|adopted]: ah held 15s, role/state 0x20000000 0x20,
[2024/10/30 14:16:56:7408] I: __lws_header_table_detach: nobody usable waiting
[2024/10/30 14:16:56:7408] I: _lws_destroy_ah: freed ah 0x5588cb380450 : pool length 0
[2024/10/30 14:16:56:7408] I: __lws_header_table_detach: [wsisrv|0|adopted]: ah 0x5588cb380450 (tsi=0, count = 0)
[2024/10/30 14:16:56:7408] D: [wsisrv|0|adopted]: __lws_vhost_unbind_wsi: vh localhost: count_bound_wsi 2
[2024/10/30 14:16:56:7409] D: [wsisrv|0|adopted]: __lws_free_wsi: tsi fds count 4
[2024/10/30 14:16:56:7409] N: localhost: __lws_lc_untag:  -- [wsisrv|0|adopted] (0) 15.018s
[2024/10/30 14:17:01:1383] I: localhost: lws_context_destroy: destroy_state 0
[2024/10/30 14:17:01:1383] I: localhost: lws_context_destroy: starting context destroy flow
[2024/10/30 14:17:01:1383] I: [vh|1|localhost||7681]: lws_context_destroy: start close
[2024/10/30 14:17:01:1383] I: [vh|1|localhost||7681]: lws_vhost_destroy1: 
[2024/10/30 14:17:01:1383] D: [wsi|1|listen|localhost||7681]: __lws_set_timeout: 0 secs, reason 1
[2024/10/30 14:17:01:1383] D: [wsi|2|listen|localhost||7681]: __lws_set_timeout: 0 secs, reason 1
[2024/10/30 14:17:01:1384] D: localhost: lws_context_destroy: pt 0: closing wsi 0x5588cb37e1e0: role pipe
[2024/10/30 14:17:01:1384] I: [wsi|0|pipe]: __lws_close_free_wsi: caller: ctx destroy
[2024/10/30 14:17:01:1384] D: [wsi|0|pipe]: __lws_close_free_wsi: real just_kill_connection A: (sockfd 4)
[2024/10/30 14:17:01:1384] I: [wsi|0|pipe]: __lws_close_free_wsi: real just_kill_connection: sockfd 4
[2024/10/30 14:17:01:1384] D: [wsi|0|pipe]: lwsi_set_state: lwsi_set_state 0x200 -> 0x20
[2024/10/30 14:17:01:1384] I: [wsi|0|pipe]: __lws_close_free_wsi: cce=0
[2024/10/30 14:17:01:1384] D: [wsi|0|pipe]: __lws_close_free_wsi_final: fd 4
[2024/10/30 14:17:01:1396] D: [wsi|0|pipe]: __lws_free_wsi: tsi fds count 3
[2024/10/30 14:17:01:1396] N: localhost: __lws_lc_untag:  -- [wsi|0|pipe] (2) 29.672s
[2024/10/30 14:17:01:1396] D: localhost: lws_context_destroy: pt 0: closing wsi 0x5588cb37f510: role listen
[2024/10/30 14:17:01:1396] I: [wsi|2|listen|localhost||7681]: __lws_close_free_wsi: caller: ctx destroy
[2024/10/30 14:17:01:1396] D: [wsi|2|listen|localhost||7681]: __lws_close_free_wsi: real just_kill_connection A: (sockfd 7)
[2024/10/30 14:17:01:1396] I: [wsi|2|listen|localhost||7681]: __lws_close_free_wsi: real
lws-team commented 3 weeks ago

It seems you just need to bind the mount to your http protocol

diff --git a/minimal-examples-lowlevel/ws-server/minimal-ws-server/minimal-ws-server.c b/minimal-examples-lowlevel/ws-server/minimal-ws-server/minimal-ws-server.c
index 0d969154..cc3c0f6a 100644
--- a/minimal-examples-lowlevel/ws-server/minimal-ws-server/minimal-ws-server.c
+++ b/minimal-examples-lowlevel/ws-server/minimal-ws-server/minimal-ws-server.c
@@ -39,7 +39,7 @@ static const struct lws_http_mount mount = {
        /* .mountpoint */               "/",            /* mountpoint URL */
        /* .origin */                   "./mount-origin",  /* serve from dir */
        /* .def */                      "index.html",   /* default filename */
-       /* .protocol */                 NULL,
+       /* .protocol */                 "http",
        /* .cgienv */                   NULL,
        /* .extra_mimetypes */          NULL,
        /* .interpret */                NULL,
stevensonkd commented 3 weeks ago

That fixed it. Thanks!