Re: [jetty-users] How to catch HTTP2 "101 switching protocol" messages ?
On Tue, Sep 8, 2015 at 12:52 PM, Pierre De Rop <pierre.derop@xxxxxxxxx> wrote:
> Hello Simone;
> The protocol between our LB and jetty based http agent is a binary
> proprietary protocol (I can't provide here the exact binary content), and we
> can't use the jetty PROXY protocol between our LB and the http agents.
> So, let me explain better our need: when an http agent sends a HTTP2 101
> protocol switch to the LB, we need to send the "special message" to the LB
> (before the HTTP2 101). This "special message" is part of the proprietary
> protocol between the LB and the http agent, and is really similar to the 101
> protocol switch: it just tells to the LB that a protocol switch will take
> place. We have to do this because the LB does not currently parse the real
> HTTP2 101 responded by jetty from the http agent.
> There is actually a similar scenario when using Jetty Web Sockets: when a
> web socket client sends an initial request with some upgrade informations,
> then the jetty running inside the http agent sends a 101 http response in
> order to announce the switch to the Web Sockets protocol.
> So, here we have the same need and we want to send the "special message" to
> the LB before the 101 is sent.
> To do so, we are using the following trick which works for Web Sockets: we
> are attaching a RequestLogHandler to the org.eclipse.jetty.server.Server
> object (inside the http agent jvm), and when the 101 is about to be sent to
> the LB, our RequestLogHandler is first called and at this exact point, we
> are then sending the "special message" to the LB before the Web Socket 101
> reponse is sent.
> So, this does not seem to work in the context of HTTP2, and our
> RequestLogHandler is not called with the HTTP2 101 response. Is this
> something that is just impossible to do using HTTP2 ? If not, then we'll
> have to consider some other approach.
HTTP/2 is multiplexed, which means that on the same TCP connection you
can have multiple HTTP requests.
If Request1 is a normal GET, Request2 is a normal POST, and Request3
is your upgrade request that is responded with a 101, then the load
balancer cannot "switch" protocol, because Request1 and Request2 will
still be HTTP, while Request3 will now talk the new, upgraded,
protocol (well, in theory it could, but I'm pretty sure it won't
There are proposals to carry WebSocket frames inside HTTP/2 frames,
but nothing standard yet.
In summary, I don't think it can work in general. If you need a
protocol upgrade, it's probably best you start the upgrade from
HTTP/1.1, not HTTP/2.
Developer advice, training, services and support
from the Jetty & CometD experts.