Skip to content

Conversation

lhoguin
Copy link
Contributor

@lhoguin lhoguin commented Sep 3, 2025

This PR:

  • Updates Cowboy and Cowlib
  • Enables HTTP/2 in Web-STOMP
  • Enables HTTP/2 Websocket by default in Web-MQTT and Web-STOMP

Testing requires some configuration because the plugins don't enable TLS by default. I have made the following edit to make it work. Make sure to update the paths:

Details

diff --git a/deps/rabbitmq_web_mqtt/Makefile b/deps/rabbitmq_web_mqtt/Makefile
index 0ba7dbcec2..4024ccdbbc 100644
--- a/deps/rabbitmq_web_mqtt/Makefile
+++ b/deps/rabbitmq_web_mqtt/Makefile
@@ -4,8 +4,13 @@ PROJECT_MOD = rabbit_web_mqtt_app
 
 define PROJECT_ENV
 [
-	    {tcp_config, [{port, 15675}]},
-	    {ssl_config, []},
+	    {tcp_config, []},
+	    {ssl_config, [{port, 15675},
+
+                    {certfile,   "/home/essen/ninenines/cowboy/examples/ssl_hello_world/priv/ssl/cert.pem"},
+                    {keyfile,    "/home/essen/ninenines/cowboy/examples/ssl_hello_world/priv/ssl/key.pem"},
+                    {verify,     verify_none}
+        ]},
 	    {num_tcp_acceptors, 10},
 	    {num_ssl_acceptors, 10},
 	    {cowboy_opts, []},
diff --git a/deps/rabbitmq_web_mqtt_examples/Makefile b/deps/rabbitmq_web_mqtt_examples/Makefile
index 78151d80d9..79e1260d98 100644
--- a/deps/rabbitmq_web_mqtt_examples/Makefile
+++ b/deps/rabbitmq_web_mqtt_examples/Makefile
@@ -4,7 +4,12 @@ PROJECT_MOD = rabbit_web_mqtt_examples_app
 
 define PROJECT_ENV
 [
-	    {listener, [{port, 15670}]}
+	    {listener, [{port, 15670},
+                    {ssl, true},
+                    {certfile,   "/home/essen/ninenines/cowboy/examples/ssl_hello_world/priv/ssl/cert.pem"},
+                    {keyfile,    "/home/essen/ninenines/cowboy/examples/ssl_hello_world/priv/ssl/key.pem"},
+                    {verify,     verify_none}
+        ]}
 	  ]
 endef
 
diff --git a/deps/rabbitmq_web_stomp/Makefile b/deps/rabbitmq_web_stomp/Makefile
index 131f9df3ce..3ca8e53739 100644
--- a/deps/rabbitmq_web_stomp/Makefile
+++ b/deps/rabbitmq_web_stomp/Makefile
@@ -4,8 +4,12 @@ PROJECT_MOD = rabbit_web_stomp_app
 
 define PROJECT_ENV
 [
-	    {tcp_config, [{port, 15674}]},
-	    {ssl_config, []},
+	    {tcp_config, []},
+	    {ssl_config, [{port, 15674},
+                    {certfile,   "/home/essen/ninenines/cowboy/examples/ssl_hello_world/priv/ssl/cert.pem"},
+                    {keyfile,    "/home/essen/ninenines/cowboy/examples/ssl_hello_world/priv/ssl/key.pem"},
+                    {verify,     verify_none}
+        ]},
 	    {num_tcp_acceptors, 10},
 	    {num_ssl_acceptors, 10},
 	    {cowboy_opts, []},
@@ -34,4 +38,4 @@ DEP_PLUGINS = rabbit_common/mk/rabbitmq-plugin.mk
 include ../../rabbitmq-components.mk
 include ../../erlang.mk
 
-CT_HOOKS = rabbit_ct_hook
\ No newline at end of file
+CT_HOOKS = rabbit_ct_hook
diff --git a/deps/rabbitmq_web_stomp_examples/Makefile b/deps/rabbitmq_web_stomp_examples/Makefile
index c45e738020..eab9ba9943 100644
--- a/deps/rabbitmq_web_stomp_examples/Makefile
+++ b/deps/rabbitmq_web_stomp_examples/Makefile
@@ -4,7 +4,12 @@ PROJECT_MOD = rabbit_web_stomp_examples_app
 
 define PROJECT_ENV
 [
-	    {listener, [{port, 15670}]}
+	    {listener, [{port, 15670},
+                    {ssl, true},
+                    {certfile,   "/home/essen/ninenines/cowboy/examples/ssl_hello_world/priv/ssl/cert.pem"},
+                    {keyfile,    "/home/essen/ninenines/cowboy/examples/ssl_hello_world/priv/ssl/key.pem"},
+                    {verify,     verify_none}
+        ]}
 	  ]
 endef
 

I have been using Firefox to test and had to enable network.http.http2.websockets in about:config as it was disabled by default for me.

@mergify mergify bot added the make label Sep 3, 2025
num_conns_sups => get_env(num_conns_sup, 1)
},
case cowboy:start_tls(RanchRef, RanchTransportOpts, CowboyOpts) of
case cowboy:start_tls(RanchRef, RanchTransportOpts, CowboyOpts#{enable_connect_protocol => true}) of
Copy link
Contributor Author

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.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume the reasons to potentially not force HTTP/2 WebSockets has to do with client compatibility?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, especially because the rollout of HTTP/2 Websocket in browsers is not yet complete, so there may be unforeseen issues. It's also lacking real world testing in Cowboy.

@lhoguin lhoguin changed the title DO NOT MERGE Use Cowboy's new direct data delivery for HTTP/2 Websocket DO NOT MERGE Enable HTTP/2 Websocket in Web plugins by default Sep 12, 2025
@lhoguin

This comment was marked as outdated.

@lhoguin lhoguin force-pushed the loic-cowboy-data_delivery-relay branch 2 times, most recently from 1e35647 to 27d3aa7 Compare September 18, 2025 12:17
@lhoguin
Copy link
Contributor Author

lhoguin commented Sep 18, 2025

I have only done manual testing of this so far. I would like to have tests in CI but as the feature freeze approaches I am focusing on finishing up the feature part of it. I will go back to adding tests once I have done the equivalent work for Web-AMQP10 in Tanzu. In the meantime this can be manually tested.

@lhoguin lhoguin marked this pull request as ready for review September 18, 2025 12:53
@lhoguin lhoguin changed the title DO NOT MERGE Enable HTTP/2 Websocket in Web plugins by default Enable HTTP/2 Websocket in Web plugins by default Sep 18, 2025
@lhoguin

This comment was marked as outdated.

This uses Cowboy's new direct data delivery mechanism,
which provides more performance.

Cowboy is now pinned to 2.14.0 and Cowlib to 2.16.0.

HTTP/2 Websocket is enabled by default. It can be disabled
as needed by setting `#{enable_connect_protocol => false}`
in the plugin's `cowboy_opts`.

Web-STOMP did not have HTTP/2 enabled before, now it does.
Web-MQTT already had HTTP/2 enabled.
@lhoguin lhoguin force-pushed the loic-cowboy-data_delivery-relay branch from 27d3aa7 to 725c2d5 Compare September 19, 2025 09:28
@lhoguin
Copy link
Contributor Author

lhoguin commented Sep 19, 2025

This is ready.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants