You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Sep 25, 2023. It is now read-only.
We're writing a custom operator using Quarkus and the fabric8 kubernetes-client. When writing a unit test with mocking for a pods/exec request I ran into this WebSocketClientHandshakeException:
And the exception is triggered by io.netty.handler.codec.http.websocketx.WebSocketClientHandshaker.finishHandshake():
// Verify the subprotocol that we received from the server.
// This must be one of our expected subprotocols - or null/empty if we didn't want to speak a subprotocol
String receivedProtocol = response.headers().get(HttpHeaderNames.SEC_WEBSOCKET_PROTOCOL);
receivedProtocol = receivedProtocol != null ? receivedProtocol.trim() : null;
String expectedProtocol = expectedSubprotocol != null ? expectedSubprotocol : "";
boolean protocolValid = false;
if (expectedProtocol.isEmpty() && receivedProtocol == null) {
// No subprotocol required and none received
protocolValid = true;
setActualSubprotocol(expectedSubprotocol); // null or "" - we echo what the user requested
} else if (!expectedProtocol.isEmpty() && receivedProtocol != null && !receivedProtocol.isEmpty()) {
// We require a subprotocol and received one -> verify it
for (String protocol : expectedProtocol.split(",")) {
if (protocol.trim().equals(receivedProtocol)) {
protocolValid = true;
setActualSubprotocol(receivedProtocol);
break;
}
}
} // else mixed cases - which are all errors
My workaround for this is to set the missing header myself:
We're writing a custom operator using Quarkus and the fabric8
kubernetes-client
. When writing a unit test with mocking for apods/exec
request I ran into thisWebSocketClientHandshakeException
:This is our mock code:
This is our production code:
The subprotocol mentioned in the exception is set by the
kubernetes-client
inPodOperationsImpl
:And the exception is triggered by
io.netty.handler.codec.http.websocketx.WebSocketClientHandshaker.finishHandshake()
:My workaround for this is to set the missing header myself:
I think the mock server should handle this automatically, since it's defined in the protocol upgrade mechanism (and not specific to the
kubernetes-client
usage). See https://developer.mozilla.org/en-US/docs/Web/HTTP/Protocol_upgrade_mechanismThe text was updated successfully, but these errors were encountered: