-
Notifications
You must be signed in to change notification settings - Fork 4k
DO NOT MERGE Use Cowboy's new direct data delivery for HTTP/2 Websocket #14500
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,9 +56,25 @@ | |
upgrade(Req, Env, Handler, HandlerState) -> | ||
upgrade(Req, Env, Handler, HandlerState, #{}). | ||
|
||
%% We simulate PROXY headers when HTTP/2 is used to have src/dest. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not true anymore. |
||
upgrade(Req=#{version := 'HTTP/2', peer := Peer, sock := Sock, cert := Cert}, | ||
Env, Handler, HandlerState, Opts) -> | ||
logger:error("~p ~p ~p ~p ~p", [Req, Env, Handler, HandlerState, Opts]), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Obviously remove this before we are done. |
||
{SrcAddr, SrcPort} = Peer, | ||
{DestAddr, DestPort} = Sock, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps don't unwrap here, unwrap in rabbit_net functions. |
||
SocketInfo = #{ | ||
src_address => SrcAddr, | ||
src_port => SrcPort, | ||
dest_address => DestAddr, | ||
dest_port => DestPort, | ||
cert => Cert | ||
}, | ||
VirtualSocket = {rabbit_virtual_socket, SocketInfo}, | ||
cowboy_websocket:upgrade(Req, Env, Handler, HandlerState#state{socket = VirtualSocket}, Opts); | ||
upgrade(Req, Env, Handler, HandlerState, Opts) -> | ||
cowboy_websocket:upgrade(Req, Env, Handler, HandlerState, Opts). | ||
|
||
%% @todo This is only called for HTTP/1.1. | ||
takeover(Parent, Ref, Socket, Transport, Opts, Buffer, {Handler, HandlerState}) -> | ||
Sock = case HandlerState#state.socket of | ||
undefined -> | ||
|
@@ -84,7 +100,7 @@ init(Req, Opts) -> | |
stats_timer = rabbit_event:init_stats_timer()}, | ||
WsOpts0 = proplists:get_value(ws_opts, Opts, #{}), | ||
WsOpts = maps:merge(#{compress => true}, WsOpts0), | ||
{?MODULE, Req1, State, WsOpts} | ||
{?MODULE, Req1, State, WsOpts#{data_delivery => relay}} | ||
end | ||
end. | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,8 +40,8 @@ endif | |
# all projects use the same versions. It avoids conflicts. | ||
|
||
dep_accept = hex 0.3.5 | ||
dep_cowboy = hex 2.13.0 | ||
dep_cowlib = hex 2.14.0 | ||
dep_cowboy = git https://github.com/ninenines/cowboy direct-data_delivery-for-h2-websocket | ||
dep_cowlib = git https://github.com/ninenines/cowlib master | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Temporary. |
||
dep_credentials_obfuscation = hex 3.5.0 | ||
dep_cuttlefish = hex 3.5.0 | ||
dep_gen_batch_server = hex 0.8.8 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This forces enable HTTP/2 Websocket. Not necessarily what we want. If enabled by default we want to be able to disable it.