Merge pull request #1555 from wkchee/patch-1

Fixed connectivity to Google PubSub over proxy
This commit is contained in:
Michael Lumish 2020-08-31 12:03:17 -07:00 committed by GitHub
commit 4b9da2ef7b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 3 deletions

View File

@ -215,8 +215,10 @@ export function getProxiedConnection(
* connection to a TLS connection.
* This is a workaround for https://github.com/nodejs/node/issues/32922
* See https://github.com/grpc/grpc-node/pull/1369 for more info. */
const remoteHost = getDefaultAuthority(parsedTarget);
const targetPath = getDefaultAuthority(parsedTarget);
const hostPort = splitHostPort(targetPath);
const remoteHost = hostPort?.host ?? targetPath;
const cts = tls.connect(
{
host: remoteHost,

View File

@ -467,11 +467,13 @@ export class Subchannel {
* if a connection is successfully established through the proxy.
* If the proxy is not used, these connectionOptions are discarded
* anyway */
connectionOptions.servername = getDefaultAuthority(
const targetPath = getDefaultAuthority(
parseUri(this.options['grpc.http_connect_target'] as string) ?? {
path: 'localhost',
}
);
const hostPort = splitHostPort(targetPath);
connectionOptions.servername = hostPort?.host ?? targetPath;
}
}
}