Wrong port is used in proxy CONNECT directive when no port present in the endpoint URL.
corsair626 opened this issue · 2 comments
Hello,
trying to connect to an endpoint wss://<some host> using https proxy I discovered attempt to connect to <some host>:8080 while for wss it should be <some host>:443.
Proxy_connect: "CONNECT <some host>:8080 HTTP/1.1
Host: <some host>
"
Looks like the problem is caused by the following line in the Proxy_connect function (sources paho.mqtt.c-1.3.12)
FUNC_ENTRY;
-> hostname_len = MQTTProtocol_addressPort(hostname, &port, NULL, PROXY_DEFAULT_PORT);
for ( i = 0; i < 2; ++i ) {
because hostname refers to the endpoint address without port specification so default port should not be PROXY_DEFAULT_PORT.
As a workaround I propose a client to specify endpoint URL with explicit port specification.
I'm having trouble following what you're doing and what you're expecting. What are your proxy environment variable set to?
MQTT: 20230707 092636.431 Setting http proxy to 10.50.0.95:8123
MQTT: 20230707 092636.431 Setting https proxy to 10.50.0.95:8123
This is from the log
Then trying to connect to wss://some.host.com using proxy
In the log I see
MQTT: 20230707 092636.431 Proxy_connect: "CONNECT some.host.com:8080 HTTP/1.1
Host: some.host.com
"
The same is in the proxy log.
The problem is URL wss://some.host.com has no port specified so the client should connect to port 443 (because of wss:// ) but is attempting to connect to port 8080. If I set the URL as wss://some.host.com:443 the client connects successfully.
MQTT: 20230707 100440.400 Proxy_connect: "CONNECT some.host.com:443 HTTP/1.1
Host: some.host.com
"