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

Allow Route Services to be used with Web Sockets #408

Open
domdom82 opened this issue May 8, 2024 · 0 comments
Open

Allow Route Services to be used with Web Sockets #408

domdom82 opened this issue May 8, 2024 · 0 comments

Comments

@domdom82
Copy link
Contributor

domdom82 commented May 8, 2024

Proposed Change

As a developer
I want to attach a route service to my web socket app
So that I can rate-limit it using the route service

We currently prevent web socket upgrades on routes that have a route service attached.

The check is implemented here

However, there is no technical reason why route services should not be able to handle web socket requests. I've tested this by commenting out the above check and attaching a route service to a web socket app. The handshake and traffic work just fine through the route service.

So long as the route service behaves correctly as a reverse proxy and forwards the Connection: Upgrade and Upgrade: Websocket headers to the destination app, there is no reason to block it at gorouter. After all, web socket requests are just HTTP requests.

This issue has been brought up by one of our customers who need a route service to rate-limit their app and have been complaining that it didn't work with web socket apps.

Note: The check is very old. It might be outdated. We recently removed the RequestHandler and let Go do all the work for web sockets. My suspicion is that the check was added because RequestHandler didn't play well together with route services.

Acceptance criteria

Scenario: My web socket app needs rate limiting via a route service.
Given

cf push my-websocket-app
cf push ratelimiter
cf create-user-provided-service ratelimiter-service -r https://ratelimiter.bosh-lite.com
cf bind-route-service bosh-lite.com ratelimiter-service --hostname my-websocket-app

When I connect to wss://my-websocket-app.bosh-lite.com using a web socket client
Then The connection will work through the route service as expected

Related links

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

No branches or pull requests

1 participant