Skip to content

Allow Route Services to be used with Web Sockets #408

Open
@domdom82

Description

@domdom82

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status

Inbox

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions