diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/WatchConnectionManager.java b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/WatchConnectionManager.java index 2847f4d7688..986d1ce0396 100644 --- a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/WatchConnectionManager.java +++ b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/WatchConnectionManager.java @@ -55,6 +55,7 @@ import static io.fabric8.kubernetes.client.utils.Utils.isNotNullOrEmpty; import static java.net.HttpURLConnection.HTTP_GONE; +import static java.net.HttpURLConnection.HTTP_OK; public class WatchConnectionManager> implements Watch { @@ -193,6 +194,15 @@ public void onFailure(IOException e, Response response) { return; } + // We do not expect a 200 in response to the websocket connection. If it occurs, we throw + // an exception and try the watch via a persistent HTTP Get. + if (response != null && response.code() == HTTP_OK) { + queue.add(new KubernetesClientException("Received 200 on websocket", + response.code(), null)); + response.body().close(); + return; + } + if (response != null) { // We only need to queue startup failures. Status status = OperationSupport.createStatus(response);