Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed connectivity to Google PubSub over proxy #1555

Merged
merged 7 commits into from Aug 31, 2020

Conversation

wkchee
Copy link
Contributor

@wkchee wkchee commented Aug 29, 2020

Latest version has caused @google-cloud/pubsub fail to connect over a proxy connection.

Snapshot of error:

2020-08-29T10:52:45.340Z | proxy | Successfully connected to pubsub.googleapis.c
om:443 through proxy 172.16.52.252:443
2020-08-29T10:52:45.370Z | subchannel | 172.16.52.252:443 CONNECTING -> TRANSIEN
T_FAILURE
2020-08-29T10:52:45.372Z | pick_first | CONNECTING -> TRANSIENT_FAILURE
2020-08-29T10:52:45.373Z | resolving_load_balancer | dns:172.16.52.252:443 CONNE
CTING -> TRANSIENT_FAILURE
2020-08-29T10:52:45.375Z | channel | Pick result: TRANSIENT_FAILURE subchannel:
undefined status: 14 No connection established
2020-08-29T10:52:45.377Z | call_stream | [11] cancelWithStatus code: 14 details:
"No connection established"
2020-08-29T10:52:45.379Z | call_stream | [11] ended with status: code=14 details
="No connection established"
2020-08-29T10:52:45.381Z | connectivity_state | dns:172.16.52.252:443 CONNECTING
-> TRANSIENT_FAILURE

Before proposed fix:

static getDefaultAuthority(target) {
    return target.path;  // this returns "pubsub.googleapis.com:443"
}

After proposed fix:

static getDefaultAuthority(target) {
    const hostPort = uri_parser_1.splitHostPort(target.path);  // target.path is "pubsub.googleapis.com:443"
    if (hostPort !== null) {
        return hostPort.host; // this returns "pubsub.googleapis.com"
    }
    else {
        throw new Error(`Failed to parse target ${uri_parser_1.uriToString(target)}`);
    }
}

Latest version has caused @google-cloud/pubsub fail to connect over a proxy connection.


Snapshot of error:

2020-08-29T10:52:45.340Z | proxy | Successfully connected to pubsub.googleapis.c
om:443 through proxy 172.16.52.252:443
2020-08-29T10:52:45.370Z | subchannel | 172.16.52.252:443 CONNECTING -> TRANSIEN
T_FAILURE
2020-08-29T10:52:45.372Z | pick_first | CONNECTING -> TRANSIENT_FAILURE
2020-08-29T10:52:45.373Z | resolving_load_balancer | dns:172.16.52.252:443 CONNE
CTING -> TRANSIENT_FAILURE
2020-08-29T10:52:45.375Z | channel | Pick result: TRANSIENT_FAILURE subchannel:
undefined status: 14 No connection established
2020-08-29T10:52:45.377Z | call_stream | [11] cancelWithStatus code: 14 details:
 "No connection established"
2020-08-29T10:52:45.379Z | call_stream | [11] ended with status: code=14 details
="No connection established"
2020-08-29T10:52:45.381Z | connectivity_state | dns:172.16.52.252:443 CONNECTING
 -> TRANSIENT_FAILURE


Before proposed fix:

    static getDefaultAuthority(target) {
        return target.path;  // this returns "pubsub.googleapis.com:443"
    }

After proposed fix:

    static getDefaultAuthority(target) {
        const hostPort = uri_parser_1.splitHostPort(target.path);  // target.path is "pubsub.googleapis.com:443"
        if (hostPort !== null) {
            return hostPort.host; // this returns "pubsub.googleapis.com"
        }
        else {
            throw new Error(`Failed to parse target ${uri_parser_1.uriToString(target)}`);
        }
    }
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Aug 29, 2020

CLA Check
The committers are authorized under a signed CLA.

@murgatroid99
Copy link
Member

I see the problem, but the fix belongs in the proxy code (http_proxy.ts), not here. The getDefaultAuthority function is used in other places, and it needs to have the port. You should be able to directly call splitHostPort(parsedTarget.path) where it is currently calling getDefaultAuthority. Also, I don't know where you got uri_parser_1 from, but it's not a valid reference to anything. splitHostPort is already imported, so you can just call it directly.

@wkchee
Copy link
Contributor Author

wkchee commented Aug 30, 2020

Thanks for the guidance. Please can help to review the changes again.

Copy link
Member

@murgatroid99 murgatroid99 left a comment

Choose a reason for hiding this comment

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

Thank you for your contribution.

@murgatroid99 murgatroid99 merged commit 4b9da2e into grpc:master Aug 31, 2020
@wkchee wkchee deleted the patch-1 branch September 1, 2020 06:58
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.

None yet

3 participants