]> git.kaiwu.me - haproxy.git/commitdiff
BUG/MEDIUM: server: Don't use the cached ALPN for websocket
authorOlivier Houchard <ohouchard@haproxy.com>
Fri, 16 Oct 2026 15:05:11 +0000 (17:05 +0200)
committerOlivier Houchard <cognet@ci0.org>
Thu, 22 Oct 2026 15:37:27 +0000 (17:37 +0200)
When using websockets, we may end up using a different ALPN than the one
we usually use with the server, so do not reuse the cached ALPN, if any,
and do not cache the one we used for that connection. Otherwise, we may
end up with websocket connections that will attempt to use the wrong
mux, and end in error.
Not making any attempt at caching the ALPN means we can't easily use
0RTT with websockets, but I do not believe this is a big problem.

This will hopefully help with github issue #3473.

This should be backported up to 3.3.

src/backend.c

index 1c374676e25d16bd9e3504b7dc5b39a7d809aee6..2f0fe7ea27abf5ff00764e6bcf45bfc832424eb5 100644 (file)
@@ -2161,8 +2161,15 @@ int connect_server(struct stream *s)
                                break;
                        }
 
-                       if (!conn_update_alpn(srv_conn, ist(alpn), force))
+                       if (!conn_update_alpn(srv_conn, ist(alpn), force)) {
+                               /*
+                                * Possibly the ALPN will be different,
+                                * so don't use any cached value.
+                                */
+                               may_start_mux_now = 0;
+                               srv_conn->flags |= CO_FL_SSL_NO_CACHED_INFO;
                                DBG_TRACE_STATE("update alpn for websocket", STRM_EV_STRM_PROC|STRM_EV_CS_ST, s);
+                       }
                }
 #endif
        }