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

bug: WebSocketGraphQLClient handshake fails if it receives a keep alive message before connection ack #1328

Open
vincentjames501 opened this issue Nov 21, 2022 · 0 comments
Assignees
Labels
bug Something isn't working investigate

Comments

@vincentjames501
Copy link

According to the spec, it doesn't really define what should happen if the client receives a message before the connection ack message.

Some GQL servers such as Hasura (see hasura/graphql-engine#7002) will send a "ka" message immediately upon a client connecting.

The dgs client is pretty strict when it comes to what the next message should be which one could argue is one interpretation of the spec.

    private fun doHandshake(): Mono<Void> {
        return Mono.defer {
            connection.set(client.connect().subscribe())

            client.send(CONNECTION_INIT_MESSAGE)
            client.receive()
                .take(1)
                .map { message ->
                    if (message.type == GQL_CONNECTION_ACK) {
                        message
                    } else {
                        throw GraphQLException("Acknowledgement expected from server, received $message")
                    }
                }
                .timeout(acknowledgementTimeout)
                .then()
        }
    }

Since this is an internal private function it's also quite hard to override.

Expected behavior

Ideally it would be nice to be able to just skip messages until we receive the GQL_CONNECTION_ACK or timeout while maybe logging messages skipped/dropped before then?

Actual behavior

It throws an exception and aborts the connection.

reactor.core.Exceptions$ErrorCallbackNotImplemented: graphql.GraphQLException: Acknowledgement expected from server, received OperationMessage(type=ka, payload=null, id=)
Caused by: graphql.GraphQLException: Acknowledgement expected from server, received OperationMessage(type=ka, payload=null, id=)
	at com.netflix.graphql.dgs.client.WebSocketGraphQLClient$doHandshake$1$1.invoke(WebSocketGraphQLClient.kt:138)
	at com.netflix.graphql.dgs.client.WebSocketGraphQLClient$doHandshake$1$1.invoke(WebSocketGraphQLClient.kt:134)
	at com.netflix.graphql.dgs.client.WebSocketGraphQLClient.doHandshake$lambda$7$lambda$6(WebSocketGraphQLClient.kt:134)

Steps to reproduce

Point an instance of the WebSocketGraphQLClient as any Hasura subscription which will fail.

@vincentjames501 vincentjames501 added the bug Something isn't working label Nov 21, 2022
@github-actions github-actions bot added the stale label Nov 22, 2023
@asibross asibross self-assigned this Oct 31, 2024
@github-actions github-actions bot removed the stale label Nov 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working investigate
Projects
None yet
Development

No branches or pull requests

2 participants