ClickHouse/clickhouse-js

Support HTTPS endpoints in NodeCustomAgentConnection

Closed this issue · 0 comments

ereio commented

Describe the bug

When attempting to use a http proxy to then subsequently hit a https Clickhouse endpoint (like Clickhouse Cloud) we get the error:

TypeError [ERR_INVALID_PROTOCOL]: Protocol "https:" not supported. Expected "http:"

This is because there is no conditional to use the correct http(s).request impl for the specified url in NodeCustomAgentConnection.

This problem doesn't exist when not using a custom http_agent due to the code found here

 switch (connection_params.url.protocol) {
    case 'http:':
      return new NodeHttpConnection({
        ...connection_params,
        set_basic_auth_header,
        keep_alive,
      })
    case 'https:':
      return new NodeHttpsConnection({
        ...connection_params,
        set_basic_auth_header,
        keep_alive,
        tls,
      })

If you could put a similar conditional before making the http.request - to use either http.request or https.request implementation based on params.url - in the following line it would solve the problem we're experiencing