Skip to content

WSS: use hostname from URL if not specified - #4914

Open
YunYe-Pu wants to merge 1 commit into
zeromq:masterfrom
YunYe-Pu:dev-wss-hostname-from-url
Open

WSS: use hostname from URL if not specified#4914
YunYe-Pu wants to merge 1 commit into
zeromq:masterfrom
YunYe-Pu:dev-wss-hostname-from-url

Conversation

@YunYe-Pu

@YunYe-Pu YunYe-Pu commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Motivation

Currently, when using WSS client, TLS hostname must be set with ZMQ_WSS_HOSTNAME option, otherwise no SNI is sent to server, and the server may reject the handshake. This means if we want to connect one ZMQ socket to multiple WSS servers, we need to write something like this:

zmq_setsockopt(sock, ZMQ_WSS_HOSTNAME, "host1", strlen("host1"));
zmq_connect(sock, "wss://host1:443/path/to/websocket");
zmq_setsockopt(sock, ZMQ_WSS_HOSTNAME, "host2", strlen("host2"));
zmq_connect(sock, "wss://host2:443/path/to/websocket");
...

Which is a bit cumbersome compared to other transports.

Since in production, TLS without SNI is rarely used, it might be beneficial to have WSS client send the SNI by default.

Proposal

When ZMQ_WSS_HOSTNAME is empty, and when the WSS URL contains a valid domain name, use domain name in URL as the TLS hostname. ZMQ_WSS_HOSTNAME still works in case we need to override the hostname. Other wss-related options are unaffected.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant