-
Notifications
You must be signed in to change notification settings - Fork 38.6k
Description
If the web server advertises that it supports RFC 8441 via the HTTP/2 SETTINGS_ENABLE_CONNECT_PROTOCOL
parameter then some web browsers (Chrome, Firefox) will follow RFC 8441 to open a WebSocket over a HTTP/2 stream using the CONNECT
HTTP method.
The org.springframework.web.socket.server.support.AbstractHandshakeHandler#doHandshake
method however only supports the GET
method and will respond with 405 Method Not Allowed.
and log an error message: Handshake failed due to unexpected HTTP method: CONNECT
The work around is to disable RFC 8441 in your web server, e.g. with Jetty you can set org.eclipse.jetty.http2.server.AbstractHTTP2ServerConnectionFactory#setConnectProtocolEnabled
to false (the default is that it is enabled in Jetty 12 EE10).
This problem was observed in Spring 6.2.0.
Lines 172 to 179 in f8fd6da
if (HttpMethod.GET != request.getMethod()) { | |
response.setStatusCode(HttpStatus.METHOD_NOT_ALLOWED); | |
response.getHeaders().setAllow(Collections.singleton(HttpMethod.GET)); | |
if (logger.isErrorEnabled()) { | |
logger.error("Handshake failed due to unexpected HTTP method: " + request.getMethod()); | |
} | |
return false; | |
} |