Skip to content

Commit 1228259

Browse files
Merge pull request #15009 from rabbitmq/mergify/bp/v4.2.x/pr-15008
Support `mqttv3.1` WebSocket subprotocol in addition to `mqtt` (backport #15008)
2 parents 90b5530 + 89df4a2 commit 1228259

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

deps/rabbitmq_web_mqtt/src/rabbit_web_mqtt_handler.erl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,11 @@ init(Req, Opts) ->
106106
undefined ->
107107
no_supported_sub_protocol(undefined, Req);
108108
Protocol ->
109-
case lists:member(<<"mqtt">>, Protocol) of
109+
case lists:search(fun(P) -> P =:= <<"mqtt">> orelse P =:= <<"mqttv3.1">> end, Protocol) of
110110
false ->
111111
no_supported_sub_protocol(Protocol, Req);
112-
true ->
113-
Req1 = cowboy_req:set_resp_header(<<"sec-websocket-protocol">>, <<"mqtt">>, Req),
112+
{value, MatchedProtocol} ->
113+
Req1 = cowboy_req:set_resp_header(<<"sec-websocket-protocol">>, MatchedProtocol, Req),
114114
State = #state{socket = maps:get(proxy_header, Req, undefined),
115115
stats_timer = rabbit_event:init_stats_timer()},
116116
WsOpts0 = proplists:get_value(ws_opts, Opts, #{}),

0 commit comments

Comments
 (0)