Skip to content

Conversation

@guilhem
Copy link
Contributor

@guilhem guilhem commented Nov 8, 2023

http.Hijacker is mandatory to forward websocket connexions

Provide a description of what has been changed

Checklist

Fixes #618 #654

@JorTurFer
Copy link
Member

nice!
Do this add support to websockets? Could you add a record on changelog and an e2e test to cover the websockets scenario?

@JorTurFer
Copy link
Member

WDYT @t0rr3sp3dr0 ?

@guilhem
Copy link
Contributor Author

guilhem commented Nov 21, 2023

nice!
Do this add support to websockets? Could you add a record on changelog and an e2e test to cover the websockets scenario?

Yes it is ;)
I'm using it in production right now.

I really tried to add a test for websocket and UPGRADE header but without success (lack of real comprehension of current testing).
Maybe someone can help or push on my branch ^^

@JorTurFer
Copy link
Member

JorTurFer commented Nov 21, 2023

I think that we will need a special test case here, something like:

  • Custom server exposing websocket
  • A client connecting to the server through the interceptor
  • We trigger a message in the server (calling to other endpoint for example)
  • We validate that the client has received the value via webhook

Could this approach work? If yes, I'll try to include a test like it soon

Copy link
Contributor

@t0rr3sp3dr0 t0rr3sp3dr0 left a comment

Choose a reason for hiding this comment

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

Please implement a unit test to make sure we always call the underlying Hijacker method when downstreamResponseWriter implements it and another one to check the error returned when downstreamResponseWriter is not an http.Hijacker.

Also, is it safe to implement Hijack and return an error when downstreamResponseWriter is not an http.Hijacker? I'm reading the documentation and we may have problems when using HTTP/2:

The default ResponseWriter for HTTP/1.x connections supports Hijacker, but HTTP/2 connections intentionally do not. ResponseWriter wrappers may also not support Hijacker. Handlers should always test for this ability at runtime.

We need to add some HTTP/2 tests to ensure implementing this method and returning an error doesn't break anything. A code that checks whether or not HTTP.Hijacker is implemented may expect Hijack always to succeed, and we now return an error.

@hergi2004
Copy link

hergi2004 commented Jan 16, 2024

Nice!! i validate this with our app and it fixed websocket....

@JorTurFer
Copy link
Member

Nice!! i validate this with our app and it fixed websocket....

Nice to know it! Even that, we do need to include some test that ensures this will continue working during the time. @guilhem do you have any update? If the OP doesn't continue the PR, are you willing to do it @hergi2004 ?

@leblancmeneses
Copy link

leblancmeneses commented Feb 7, 2024

If you are willing to add Playwright to run the e2e test suite for this feature, I could implement a node server and have Playwright verify bidirectional communication is possible over WebSockets when HTTPScaledObject is in play.

Perhaps we can skip the middleware if Upgrade: websocket header is not present.

@JorTurFer
Copy link
Member

JorTurFer commented Feb 7, 2024

We prefer to manage all the e2e suite using go for orchestation.
Given that, client/server can be written in the language that you prefer and used as docker images and that's quite common. I mean, you can open a PR to test-tools repo generating the required docker images for client/server (or both in one, it doesn't matter) and then deploy them into the cluster and checking how it works using a test written in Go.

Could this be feasible for you?

@JorTurFer
Copy link
Member

Any update about this?

@tghastings
Copy link

I too am very interested in this merge request. Please let us know if there is anything we can do to assist moving it forward.

@JorTurFer
Copy link
Member

@tghastings , e2e test are pending yet. as the PR seems abandoned, are you willing to open another PR from here adding the e2e tests?

@JorTurFer
Copy link
Member

I fully agree with @t0rr3sp3dr0 comment: #835 (review)

We have to cover those questions with tests (unit + e2e)

@wadeperrigo
Copy link

My company has a need for this as well, any updates?

@JorTurFer
Copy link
Member

My company has a need for this as well, any updates?

Sadly the OP hasn't answered :( Are you willing to continue from this PR? The code looks well, but we need to cover it with tests to ensure that we don't break anything

@twij2332
Copy link

twij2332 commented Aug 1, 2024

This is a much needed feature. Any update on this PR?

@guilhem
Copy link
Contributor Author

guilhem commented Aug 1, 2024

I did a rebase yesterday.
I will push it tomorrow

@twij2332
Copy link

I did a rebase yesterday. I will push it tomorrow

Did you able to rebase and push

@JorTurFer
Copy link
Member

could you include e2e test coverage for this?

@twij2332
Copy link

twij2332 commented Sep 2, 2024

Seema like new changes are breaking the external-scaler deployment.

@liorshk
Copy link

liorshk commented Apr 17, 2025

Any update on this feature?

@leblancmeneses
Copy link

Finally got around to writing the websocket e2e server here: kedacore/test-tools#223 . Can someone familiar with existing test infra finish this up?

Thanks

JorTurFer pushed a commit to kedacore/test-tools that referenced this pull request Jun 3, 2025
Signed-off-by: Leblanc Meneses <[email protected]>
@JorTurFer
Copy link
Member

JorTurFer commented Jun 3, 2025

The tag with the websocket is docker pull ghcr.io/kedacore/tests-websockets:latest

@anismajd
Copy link

anismajd commented Jun 24, 2025

how can i help to get this feature done ?

@wozniakjan
Copy link
Member

wozniakjan commented Jul 25, 2025

how can i help to get this feature done ?

@anismajd The feature itself seems to be implemented already. If you could implement e2e test, that would be great. You can take some inspiration how here: https://github.com/kedacore/http-add-on/tree/main/tests/checks

@guilhem guilhem force-pushed the fixwebsocket branch 5 times, most recently from 02b7c53 to 85381db Compare August 1, 2025 14:47
@guilhem
Copy link
Contributor Author

guilhem commented Aug 1, 2025

e2e tests are implemented

@wozniakjan wozniakjan dismissed t0rr3sp3dr0’s stale review August 1, 2025 17:34

already addressed by the author

Copy link
Member

@wozniakjan wozniakjan left a comment

Choose a reason for hiding this comment

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

LGTM, thank you!

There seems to be couple of unused imports, could you please remove those?

@guilhem
Copy link
Contributor Author

guilhem commented Aug 1, 2025

There seems to be couple of unused imports, could you please remove those?

Should be ok now :)

@wozniakjan
Copy link
Member

@guilhem there are still a couple of linter complaints, can you please take a look again whenever you have a chance?

2025-08-06T16:32:16.8249315Z Running [/home/runner/golangci-lint-2.1.0-linux-amd64/golangci-lint run] in [/home/runner/work/http-add-on/http-add-on] ...
2025-08-06T16:32:32.2233408Z ##[error]interceptor/middleware/responsewriter_test.go:9:1: File is not properly formatted (gci)
2025-08-06T16:32:32.2243289Z 	"go.uber.org/mock/gomock"
2025-08-06T16:32:32.2244246Z ^
2025-08-06T16:32:32.2245551Z ##[error]tests/checks/interceptor_websocket/interceptor_websocket_test.go:101:2: const websocketClientJobTemplate is unused (unused)
2025-08-06T16:32:32.2246631Z 	websocketClientJobTemplate = `
2025-08-06T16:32:32.2246877Z 	^
2025-08-06T16:32:32.2247612Z ##[error]tests/checks/interceptor_websocket/interceptor_websocket_test.go:269:6: func testWebSocketScaleOut is unused (unused)
2025-08-06T16:32:32.2249056Z func testWebSocketScaleOut(t *testing.T, kc *kubernetes.Clientset, data templateData) {
2025-08-06T16:32:32.2249467Z      ^
2025-08-06T16:32:32.2250162Z ##[error]tests/checks/interceptor_websocket/interceptor_websocket_test.go:282:6: func testWebSocketScaleIn is unused (unused)
2025-08-06T16:32:32.2251753Z func testWebSocketScaleIn(t *testing.T, kc *kubernetes.Clientset, data templateData) {
2025-08-06T16:32:32.2252161Z      ^
2025-08-06T16:32:32.2252337Z 4 issues:
2025-08-06T16:32:32.2252536Z * gci: 1
2025-08-06T16:32:32.2252702Z * unused: 3

guilhem added 5 commits August 7, 2025 20:13
http.Hijacker is mandatory to forward websocket connexions

Signed-off-by: Guilhem Lettron <[email protected]>
Signed-off-by: Guilhem Lettron <[email protected]>
Signed-off-by: Guilhem Lettron <[email protected]>
Signed-off-by: Guilhem Lettron <[email protected]>
Signed-off-by: Guilhem Lettron <[email protected]>
@guilhem
Copy link
Contributor Author

guilhem commented Aug 7, 2025

@guilhem there are still a couple of linter complaints, can you please take a look again whenever you have a chance?

should be ok :)
I just get 2 other errors unrelated to my changes.

@wozniakjan wozniakjan enabled auto-merge (squash) August 7, 2025 21:05
@wozniakjan wozniakjan merged commit 1ae653f into kedacore:main Aug 7, 2025
18 checks passed
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.