third-wheel icon indicating copy to clipboard operation
third-wheel copied to clipboard

[REQ] WebSocket Protocol support

Open DartMen opened this issue 4 years ago • 4 comments

Consider adding websocket support to the roadmap.

DartMen avatar May 01 '21 18:05 DartMen

I know nothing about websockets but I'm interested to learn so I'm going to dig in here a little and see what's doable. It looks like someone has a crate for websockets that is compatible with hyper so at least that bit should be for free.

campbellC avatar Nov 06 '21 20:11 campbellC

@DartMen just fyi my ability to dedicate time to work on this project has dropped substantially since my personal circumstances have changed (i.e. I have a kid now).

campbellC avatar Nov 06 '21 20:11 campbellC

The RFC is pretty readable an has a ton of 'non-normative' intro type stuff. So basically websockets would come into third-wheel in two ways -

  1. an actual ws/wss request directly
  2. An upgrade to an existing HTTP connection

In the first case the proxy would need to perform the TLS handshake and upgrade the connection (as in https world) but in the second case the connection is reused so no tls trickery is required.

Once the websocket connection is established the server will need to be ready to receive messages in both directions (different to http) and capture/transform these before sending out in the other direction. The tungstenite package has an enum for the different message types here.

Needed in third-wheel then will be:

  • A way to handle connection and upgrade requests
  • Code for handling two-way messages (i.e not in a request-response pattern)
  • A new kind of third-wheel mechanism specific for websockets

We will certainly need some good testing for this - I know websockets have a lot of different use cases and use-profiles so testing here will have to be fairly wide.

campbellC avatar Nov 06 '21 20:11 campbellC

Branch for websockets. Mainly just want to add some testing to see what the current implementation does, and to get a feel for how easy this will be to support

campbellC avatar Nov 15 '21 21:11 campbellC