Skip to content

Commit a720706

Browse files
committed
Allow disabling HTTP/2 Websocket
1 parent 777d816 commit a720706

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

deps/rabbitmq_web_mqtt/src/rabbit_web_mqtt_app.erl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ start_tcp_listener(TCPConf0, CowboyOpts) ->
124124

125125

126126
start_tls_listener([], _) -> ok;
127-
start_tls_listener(TLSConf0, CowboyOpts) ->
127+
start_tls_listener(TLSConf0, CowboyOpts0) ->
128128
_ = rabbit_networking:ensure_ssl(),
129129
{TLSConf, TLSIpStr, TLSPort} = get_tls_conf(TLSConf0),
130130
RanchRef = rabbit_networking:ranch_ref(TLSConf),
@@ -135,7 +135,11 @@ start_tls_listener(TLSConf0, CowboyOpts) ->
135135
num_acceptors => get_env(num_ssl_acceptors, 10),
136136
num_conns_sups => get_env(num_conns_sup, 1)
137137
},
138-
case cowboy:start_tls(RanchRef, RanchTransportOpts, CowboyOpts#{enable_connect_protocol => true}) of
138+
CowboyOpts = CowboyOpts0#{
139+
%% Enable HTTP/2 Websocket if not explicitly disabled.
140+
enable_connect_protocol => maps:get(enable_connect_protocol, CowboyOpts0, true)
141+
},
142+
case cowboy:start_tls(RanchRef, RanchTransportOpts, CowboyOpts) of
139143
{ok, _} ->
140144
ok;
141145
{error, {already_started, _}} ->

deps/rabbitmq_web_stomp/src/rabbit_web_stomp_handler.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ websocket_info(Msg, State) ->
291291

292292
terminate(_Reason, _Req, State = #state{proc_state = undefined}) ->
293293
terminate_heartbeaters(State);
294-
terminate(Reason, _Req, State = #state{proc_state = ProcState}) ->
294+
terminate(_Reason, _Req, State = #state{proc_state = ProcState}) ->
295295
_ = rabbit_stomp_processor:flush_and_die(ProcState),
296296
terminate_heartbeaters(State).
297297

deps/rabbitmq_web_stomp/src/rabbit_web_stomp_listener.erl

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ init() ->
3434
logger:set_process_metadata(#{domain => ?RMQLOG_DOMAIN_CONN}),
3535
WsFrame = get_env(ws_frame, text),
3636
CowboyOpts0 = maps:from_list(get_env(cowboy_opts, [])),
37-
CowboyOpts = CowboyOpts0#{enable_connect_protocol => true,
38-
proxy_header => get_env(proxy_protocol, false),
37+
CowboyOpts = CowboyOpts0#{proxy_header => get_env(proxy_protocol, false),
3938
stream_handlers => [rabbit_web_stomp_stream_handler, cowboy_stream_h]},
4039
CowboyWsOpts = maps:from_list(get_env(cowboy_ws_opts, [])),
4140

@@ -143,10 +142,14 @@ start_tls_listener(TLSConf0, CowboyOpts0, Routes) ->
143142
num_acceptors => NumSslAcceptors,
144143
num_conns_sups => 1
145144
},
146-
CowboyOpts = CowboyOpts0#{env => #{dispatch => Routes},
147-
middlewares => [cowboy_router,
148-
rabbit_web_stomp_middleware,
149-
cowboy_handler]},
145+
CowboyOpts = CowboyOpts0#{
146+
env => #{dispatch => Routes},
147+
middlewares => [cowboy_router,
148+
rabbit_web_stomp_middleware,
149+
cowboy_handler],
150+
%% Enable HTTP/2 Websocket if not explicitly disabled.
151+
enable_connect_protocol => maps:get(enable_connect_protocol, CowboyOpts0, true)
152+
},
150153
case ranch:start_listener(rabbit_networking:ranch_ref(TLSConf),
151154
ranch_ssl,
152155
RanchTransportOpts,

0 commit comments

Comments
 (0)