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

Websockets support #319

Closed
andrewwebber opened this issue Jan 5, 2017 · 19 comments
Closed

Websockets support #319

andrewwebber opened this issue Jan 5, 2017 · 19 comments
Assignees
Labels
enhancement Feature requests. Not bugs or questions.
Milestone

Comments

@andrewwebber
Copy link

Does Envoy support websockets as I seem to be having some issues connecting from a golang client with a golang Backend server.

@mattklein123 mattklein123 added enhancement Feature requests. Not bugs or questions. help wanted labels Jan 5, 2017
@mattklein123
Copy link
Member

No, we don't currently support websockets.

@andrewwebber
Copy link
Author

This is very useful information as I will stop trying to find a workaround for this. I guess I will have to refactor my push microservice to use HTTP2 somehow

@mattklein123
Copy link
Member

Going to reopen just to track the feature request.

@mattklein123 mattklein123 reopened this Jan 5, 2017
@andrewwebber
Copy link
Author

Traefik claims to support HTTP2 as well as websockets. What is the limitation here...

traefik/traefik#8

@mattklein123
Copy link
Member

The limitation is we don't support the websocket protocol. :)

It needs to get implemented, probably just as a new L4 filter that sits in front of the tcp_proxy filter.

@rshriram
Copy link
Member

rshriram commented Mar 6, 2017

Based on gitter conversations with @mattklein123

make a new filter, use the http1 codec, handle the “upgrade", then just transition to straight tcp proxy semantics. Could probably just implement as as filter that sits in front of tcp_proxy, or use the existing http1 codec_impl to do the initial handshake then just pass through data to tcp_proxy.

@andrewwebber
Copy link
Author

@rshiram do you have an example JSON confirm you could share?

@rshriram
Copy link
Member

rshriram commented Mar 6, 2017

@andrewwebber this feature is not implemented yet. I was merely logging our conversations in this topic.

@captjt
Copy link

captjt commented May 18, 2017

Is there a potential timeline or update whether or not Envoy will support websockets?

@mattklein123
Copy link
Member

@jtaylor32 no, no update. Need someone to sign up to implement this.

@mattklein123
Copy link
Member

@rshriram I looked through the code and IMO this is the easiest/cleanest way to implement the required functionality. Let's discuss here if there are questions. cc @htuch

  • We should explicitly specify in the route configuration whether a route is a WS route or not. Meaning, we will not support attempting to detect if it is WS all the way back to the backend. If we receive a WS upgrade over HTTP/1.1, we will check the route table to see if the matched route is WS, and if not, fail the request with 400 or some other code.
  • In ConnectionManagerImpl::ActiveStream::decodeHeaders, we will check if 1) connection is HTTP/1.1, WS upgrade is requested, and consult the route table to check if route match is WS route. Note that internally in the http/1.1 codec, http_parser should correctly raise message complete for an upgrade request after the headers, thus we should see end_stream set to true in the above call. (There may be small logic changes required in the codec to make sure this is true but they should be simple.)
  • If we detect that we are going to enter WS mode when we get headers, we will not enter filter chain processing, and will instead shift the connection manager into a WS processing mode.
  • For this we should make an entirely new interface and impl so that it's easy to test this behavior. Basically the conn_man will create a WsHandlerImpl which implements the WsHandler interface.
  • The main entry point for this interface once the conn_man enters WS mode will be inside ConnectionManagerImpl::onData. If in WS mode, we will dispatch data from the connection directly into the WS handler, and skip the HTTP codec.
  • The WS handler implementation can send the upgrade headers to the backend via a raw TCP connection (load balanced per normal via the cluster manager), and then just start proxying data a-la TcpProxy. There is probably some ability to share code between WsHandlerImpl and TcpProxy so need to look at that.

These are rough notes but should be good enough to get started. LMK if you have more detailed questions and we can figure it out.

@rshriram
Copy link
Member

rshriram commented Jun 22, 2017 via email

@htuch
Copy link
Member

htuch commented Jun 22, 2017

Why can't Envoy terminate the websockets and speak plain TCP to the backend? This seems a reasonable ask.

@rshriram
Copy link
Member

rshriram commented Jun 22, 2017 via email

@htuch
Copy link
Member

htuch commented Jun 22, 2017

I think what's being asked here is that you have a nodejs TCP application (to continue the example), which does not speak HTTP or websockets. We have a browser client that speaks websockets. Envoy could act as a bridge from the client to the nodejs TCP application. Is this what you were thinking of @politician?

@mattklein123
Copy link
Member

If there is a use case that involves WS <-> TCP without the upgrade headers, that will be trivial to implement via a configuration option, so we can cross that bridge when we come to it.

@mattklein123 mattklein123 modified the milestone: 1.4.0 Jul 12, 2017
htuch pushed a commit that referenced this issue Jul 14, 2017
This is the first of the PRs for enabling websocket support in Envoy.
Currently, we strip upgrade and connection headers. For websocket support, we need to allow these headers to pass through if Connection: upgrade and Upgrade: websocket.
c.f. #319
@mattklein123
Copy link
Member

Fixed by #1274. Thanks @rshriram !

rshriram pushed a commit to rshriram/envoy that referenced this issue Oct 30, 2018
Automatic merge from submit-queue.

[DO NOT MERGE] Auto PR to update dependencies of mixerclient

This PR will be merged automatically once checks are successful.
```release-note
none
```
yxue pushed a commit to yxue/envoy that referenced this issue Dec 3, 2019
Signed-off-by: Yuki Ito <mrno110y@gmail.com>
@Nevon
Copy link

Nevon commented Jun 21, 2020

If there is a use case that involves WS <-> TCP without the upgrade headers, that will be trivial to implement via a configuration option, so we can cross that bridge when we come to it.

Years later now, but does anyone know if this is possible now? I have my own hand-rolled application for WS<->TCP communication, but I was hoping that I could replace it with Envoy.

@gopakumarce
Copy link

Not sure where to ask a question - the question is to what extent does envoy act as a proxy for websocket ? After the Upgrade handshake is done, does it ever look into the websocket framing itself / does it care about the websocket data being proper - or does it just treat it as a tcp after wards ?

The reason for asking is to know whether I can use an http upgrade sequence and then send non-websocket data over that connection assuming my client and server are in my control - will envoy have any unhappiness with that ?

jpsim pushed a commit that referenced this issue Nov 28, 2022
Signed-off-by: Mike Schore <mike.schore@gmail.com>
Signed-off-by: JP Simard <jp@jpsim.com>
jpsim pushed a commit that referenced this issue Nov 29, 2022
Signed-off-by: Mike Schore <mike.schore@gmail.com>
Signed-off-by: JP Simard <jp@jpsim.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Feature requests. Not bugs or questions.
Projects
None yet
Development

No branches or pull requests

7 participants